B. Mister B and Angle in Polygon 421.div2

2023-05-16

B. Mister B and Angle in Polygon
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).

That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1v2v3 such that the angle (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value  should be minimum possible.

If there are many optimal solutions, Mister B should be satisfied with any of them.

Input

First and only line contains two space-separated integers n and a (3 ≤ n ≤ 1051 ≤ a ≤ 180) — the number of vertices in the polygon and the needed angle, in degrees.

Output

Print three space-separated integers: the vertices v1v2v3, which form . If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.

Examples
input

3 15
output

1 2 3
input

4 67
output

2 1 3
input

4 68
output

4 1 2
Note

In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.

Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".

In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".

题意:就是给你一个正则凸n变形,确定一定由三个不同定点构成的角,是的这个角-a的绝对值最小。

思路:利用的是同一个圆上等弧对应的圆周角相等,所以固定一个定点,枚举一边就ok了。

上代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
  double n,a;
  while(scanf("%lf%lf",&n,&a) != EOF)
  {
     
     int nn = n;
     int i,j;
     double tmp;
     int x,y;
     double out=360.0;
     double cc = (n-2)*180.0/n;
     for(i=2; i<=2; i++)
     {
         for(j=i+1; j<=n; j++)
         {
            tmp = ((j-2)*180.0 - cc*(j-2)) / 2.0;
            
            if(fabs(tmp-a) < out){x=i,y=j; out=fabs(tmp-a);}
            if(out<= 0.00001) break;
         }
         
     }
     
     printf("%d 1 %d\n",x,y);
    }
    return 0;
}

水波。

 
Codeforces Round #421 (Div. 2)
Finished
Practice
Add to favourites
 
 
→ Virtual participation
Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never 
use someone else's code, read the tutorials or communicate with other person during a virtual contest.
 
 
→ Practice
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
 
 
→ Submit?
Language:
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                          
  •                      
  • Choose file:
    Be careful: there is 50 points penalty for submission which fails the pretests or resubmission (except failure on the first test, denial of judgement or similar verdicts). "Passed pretests" submission verdict doesn't guarantee that the solution is absolutely correct and it will pass system tests.
     
     
    → Last submissions
    SubmissionTimeVerdict
    28104928Jun/28/2017 01:59Accepted
    28104865Jun/28/2017 01:49Time limit exceeded on test 6
    28104856Jun/28/2017 01:47Wrong answer on test 1
    28098288Jun/27/2017 19:34Time limit exceeded on pretest 6
     
     
    → Problem tags
    No tags yet
    No tag edit access
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

    B. Mister B and Angle in Polygon 421.div2 的相关文章

    • 从两个角度算出顺时针转还是逆时针转

      我正在 XNA 中制作游戏 我有敌人和玩家 敌人应该逐渐转向玩家 他们应该弄清楚是否需要顺时针转动或逆时针转动 以较短者为准 我通过使用 Atan2 得到了敌人当前面对的角度和它应该面对的角度 敌人和玩家之间的线的角度 作为弧度 不过我有一
    • 沿一个坐标轴的 3D 倾斜变换矩阵

      有没有一种方法可以计算沿一个坐标轴的倾斜变换矩阵 给定倾斜角度 如下 这应该在很大程度上适用于使用变换矩阵倾斜对象 特别是使用 glMultMatrix matrix matrix1 1 0 0 0 tan a 1 0 0 0 0 1 0
    • 用R计算多个多边形之间的最小距离

      我对 R 和 sf 包还是有点陌生 我有两组多边形数据正在尝试分析 我的第一组多边形 火灾 包含数百个野火周界 第二组 城镇 包含数百个城市区域边界 对于每次火灾 我想计算到最近城镇的距离 火灾多边形边缘到最近城镇多边形边缘 并将其作为字段
    • 如何使用 angularjs 在 ngMap 中使用硬编码值绘制多边形

      我需要使用硬编码值在谷歌地图上绘制多边形 我使用了 ngMap https ngmap github io https ngmap github io 并使用了 ngMap 的绘图管理器 因为我也希望用户动态绘制多边形 如果我使用绘图管理器
    • 为什么我们需要对凸多边形进行三角剖分才能从中均匀采样?

      假设我想对凸多边形内的点进行均匀采样 这里和互联网上描述的最常见的方法之一通常包括对多边形进行三角测量 并使用不同的方案在每个三角形内生成均匀的随机点 我发现最实用的方法是从均匀分布生成指数分布 例如 log U 并将总和标准化为 1 在
    • 有没有办法让 CGAL 的折线简化适用于内部/共享边界?

      我一直在尝试借助此方法对属于地图的多边形进行线条简化CGAL指南 https doc cgal org latest Polyline simplification 2 index html 例如韩国 这是一个韩国截图 https i st
    • 寻找一种非“蛮力”算法来删除矩形集合的相交区域

      我有一个 n 大小的矩形集合 其中大部分彼此相交 我想删除相交并将相交的矩形减少为较小的非相交的矩形 我可以轻松地暴力破解解决方案 但我正在寻找一种有效的算法 这是一个可视化 原来的 处理 理想情况下 方法签名如下所示 public sta
    • 如何简化复杂的多边形?

      最近我一直在思考如何将复杂的多边形转换为非复杂的多边形 这是怎么做到的 这就是我想做的事情 完成后我将使用 JavaScript 但任何形式的解决方案都可以 语言 算法或简单的英语 我将使用与手动绘制多边形时相同的启发式 这可能不是计算该多
    • 球体表面上的射线-多边形交点

      我有一个点 纬度 经度 和一个以度为单位的航向 正北 该点沿着该点行进 我有许多固定多边形 以纬度 经度定义的点 它们可能是凸的 也可能不是凸的 我的问题是 如何计算与多边形最近的交点 如果有 我看过一些关于光线追踪的令人困惑的帖子 但当光
    • 谷歌是如何获得地图上邮政编码的轮廓的?

      例如 http g co maps 2dpkj http g co maps 2dpkj有邮政编码区域周围的轮廓 我知道这无法通过 API 获得 但我还可以从哪里获取此数据 例如 KML 格式 这是英国数据 最有可能的Google 与英国地
    • 绘制可调整大小(不相交)的多边形

      我到处寻找但找不到答案 我 需要通过鼠标交互绘制可调整大小的多边形 但我 不希望出现不规则 重叠或相交的多边形 结尾 这是绘制可调整大小的多边形的简单示例http www wolfpil de polygon html http www w
    • 根据旋转角度计算XY运动?

      假设我在 2D 空间中有一个可以旋转的对象 然后应该根据其旋转角度移动 例如 如果角度为0 指向上方 则on timer它应该将 1 移动 Y 将 0 移动 X 如果角度为 45 那么它应该按 Y 移动 1 按 X 移动 1 如果指向 90
    • 如何使用 start 和 endAngle 渲染 svg 圆

      我使用 start 和 endAngle 渲染了 svg 圆 效果很好 但是当我渲染完整的圆 startAngle为70 endAngle为70 时 输出有很大的不同 0 90 180 270除外 我为这段代码做错了什么 function
    • 确定线段是否与多边形相交

      如果我在 2D 平面上有一个向量 由 2 个点组成的线 我如何确定它是否穿过多边形 我知道我可以采用构成多边形的每条线并查看是否有相交 但有更好的方法吗 我读过这篇文章如何确定 2D 点是否在多边形内 https stackoverflow
    • OpenGL Z 偏置(多边形偏移)限制

      我有两个共面的多边形 我尝试做 glEnable GL POLYGON OFFSET FILL glPolygonOffset 0 1 并期望其中一个明显 位于 另一个之上 这种情况直到大约 70 75 个单位之外 近剪裁平面为 1 远剪裁
    • 如何确定多边形点列表是否按顺时针顺序排列?

      有了一个点列表 如何找到它们是否按顺时针顺序排列 例如 point 0 5 0 point 1 6 4 point 2 4 5 point 3 1 5 point 4 1 0 会说它是逆时针的 或者对某些人来说是逆时针的 对于非凸多边形 例
    • 生成落在多边形或形状内的点网格的最快方法?

      我在 python 中使用 shapely 并尝试在网格中生成均匀间隔的点 这些点在最快的 O n 时间内落在形状内 形状可以是任何闭合多边形 而不仅仅是正方形或圆形 我目前的做法是 找到最小 最大 y 和 x 来构建一个矩形 给定间距参数
    • XNA 2D 矢量角度 - 正确的计算方法是什么?

      在 2D 中的 XNA 中矢量角度的标准工作方式是什么 向右 0 度 向上 90 度 向左 180 度 向下 270 度 什么是 标准 实现 float VectortoAngle Vector2 vec and Vector2 Angle
    • 如何最小化两个子多边形的最大纵横比?

      我想使用直线将凸多边形切成给定面积比的两部分 以使两个子多边形的较大纵横比最小化 目前我的方法包括选择一个随机起点 计算将多边形分割成目标区域的适当终点 然后计算两个纵横比中较大的一个 然后重复这个很多次 直到我足够接近最小值 多边形 A
    • 多边形内的 SQL 地理点在 STIntersect 上不返回 true(但使用 Geometry 返回 true)

      我不想仅仅为了在 STIntersect 中返回 true 而将地理数据转换为几何图形 下面是 SQL 中的代码 DECLARE point GEOGRAPHY GEOGRAPHY Point 1 1 4326 DECLARE polygo

    随机推荐

    • Angular:formGroup中嵌套formArray,在formArray中存放的可编辑table中的字段的动态展示

      今天做的项目中做了一个新增页面 xff0c 其中最顶级是一个formGroup表单命名为editClauseForm xff0c 里面有几个单独的字段 xff0c 还有一个嵌套的formArray xff0c 命名为clauseArr xf
    • 【Java系列-6】Java实现:有1、2、3、4这4个数字,能组成多少个互不相同且无重复数字的三位数、都是多少

      Java系列 6 Java实现 xff1a 有1 2 3 4这4个数字 xff0c 能组成多少个互不相同且无重复数字的三位数 xff1f 都是多少 xff1f 1 问题 Java实现 xff1a 有1 2 3 4这4个数字 xff0c 能组
    • 【C、C++系列-10】C语言实现:百钱买百鸡问题

      C C 43 43 系列 10 C语言实现 xff1a 百钱买百鸡问题 1 问题 百钱买百鸡问题 xff1a 我国古代数学家张丘建在 算经 一书中曾提出过著名的 百钱买百鸡 问题 该问题叙述如下 xff1a 鸡翁一 xff0c 值钱五 xf
    • Android 通知使用权

      1 创建service extends NotificationListenerService xff0c 并实现onNotificationRemoved onNotificationPosted public class Notific
    • Android 系统文件浏览器

      1 调用系统文件浏览器 Intent intent 61 new Intent Intent ACTION GET CONTENT intent setType 34 34 设置类型 xff0c 我这里是任意类型 xff0c 任意后缀的可以
    • Android 导入导出excel xls、xlsx

      1 导入依赖 implementation group 39 org apache poi 39 name 39 poi ooxml 39 version 39 3 17 39 implementation group 39 org apa
    • Android 导出PDF PdfDocument

      导出PDF 64 param view 要导出的view xff0c 如果view高度过高 xff08 超过一屏的高度 xff09 xff0c 在改view外部套一层Scrollview即可 如果要导出列表类型View 比如Listview
    • Android 获取所有短信-彩信

      1 权限 lt 读取短信 gt lt uses permission android name 61 34 android permission READ SMS 34 gt lt uses permission android name
    • Photoshop CC 2018 安装包安装教程

      Photoshop CC 2018功能特点 1 更紧密连接的 Photoshop 全新的智慧型锐利化 2 智慧型增加取样 内含 Extended 功能 Camera RAW 8 和图层支援 3 可编辑的圆角矩形 多重形状和路径选择 相机防手
    • 【原创】什么是原码、反码、补码?

      原码 反码 补码是计算机中对数字的二进制表示方法 原码 xff1a 将最高位作为符号位 xff08 0表示正 xff0c 1表示负 xff09 xff0c 其它数字位代表数值本身的绝对值的数字表示方式 反码 xff1a 如果是正数 xff0
    • snprintf中的错误,不要出现目标地址也是源地址的情况

      在使用snprintf时 xff0c 千万要注意一点 xff0c 不要出现目标地址也是源地址的情况 看如下例子 xff1a span class token macro property span class token directive
    • Linux下的shell进度条

      一 关于Shell Shell的作用是解释执行用户的命令 xff0c 它有两种执行命令的方式 xff1a 交互式和批处理 Shell脚本和编程语言很相似 xff0c 也有变量和流控制语句 xff0c 但Shell脚本是解释执行 xff0c
    • you-get相关使用命令

      you get i url 获取视频格式 清晰度等信息 you get o E folder url 保存路径 在当前目录的路径栏 输入cmd即可打开命令行 或者 shift 右键 用powershell打开 you get p PotPl
    • Spring Cloud从入门到放弃(四):Eureka的常用配置

      前言 Spring Cloud系列 点击查看Spring Cloud系列文章 eurka的常用配置 eureka server前缀的配置项 是否允许开启自我保护模式 xff0c 缺省 xff1a span class token boole
    • STM32之点亮LED

      学习一个新的处理器 xff0c 第一个程序肯定就是点亮LED xff0c 它可以让我们较快的 较清晰的了解到一个处理器的程序结构 xff0c 学习32也不例外 xff0c 首先第一个程序我们就来点亮LED xff0c 点亮LED程序有很多种
    • 判断两条线段是否相交

      判断两条直线是否相交有两步 xff1a 1 xff1a 快速排斥 xff08 可以筛除大部分 xff09 2 xff1a 跨立试验 xff08 下面会有所说明 xff09 现在开始解释 xff1a 第一步快速排斥 xff0c 实际上就是先判
    • 2015-2016 ACM-ICPC Pacific Northwest Regional Contest Div.2( Problem V Gears)

      题目地址 xff1a 点击打开链接 题意 xff1a 给你很多齿轮 xff0c 让你判断第一个齿轮和第n个齿轮的关系 有三种关系题目中已经给出 解题思路 xff1a 算是比较直观的一个dfs题目了 xff0c 重点是怎么样处理这个dfs 结
    • 免费馅饼(简单动态规划)

      都说天上不会掉馅饼 xff0c 但有一天gameboy正走在回家的小径上 xff0c 忽然天上掉下大把大把的馅饼 说来gameboy的人品实在是太好了 xff0c 这馅饼别处都不掉 xff0c 就掉落在他身旁的10米范围内 馅饼如果掉在了地
    • CF816B-Karen and Coffee

      B Karen and Coffee time limit per test2 5 seconds memory limit per test512 megabytes inputstandard input outputstandard
    • B. Mister B and Angle in Polygon 421.div2

      B Mister B and Angle in Polygon time limit per test 2 seconds memory limit per test 256 megabytes input standard input o