codeforces820B Mister B and Angle in Polygon 2017-06-28 09:42 123人阅读 评论(0) 收藏
2 seconds
256 megabytes
standard input
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 v1, v2, v3 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.
First and only line contains two space-separated integers n and a (3 ≤ n ≤ 105, 1 ≤ a ≤ 180) —
the number of vertices in the polygon and the needed angle, in degrees.
Print three space-separated integers: the vertices v1, v2, v3,
which form .
If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in
clockwise order.
3 15
1 2 3
4 67
2 1 3
4 68
4 1 2
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凸多边形,让你选择3个顶点所成角度尽可能接近给出的角度k
思路:我们选一个顶点把他和与他不相邻的点连线一定会把一个角(n-2)等分,枚举选择的角度与k比就好了
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define LL long long
const int inf=0x3f3f3f3f; int main()
{
int n,x;
scanf("%d%d",&n,&x);
double p=180.0/n;
double ans=inf;
int cnt=-1;
for(int i=1; i<=n-2; i++)
{
if(fabs(ans-x)-fabs(p*i-x)>1e-9)
ans=p*i,cnt=i;
}
printf("%d %d %d\n",n-cnt,1,n);
return 0;
}
codeforces820B Mister B and Angle in Polygon 2017-06-28 09:42 123人阅读 评论(0) 收藏的更多相关文章
- Codeforces820A Mister B and Book Reading 2017-06-28 09:38 67人阅读 评论(0) 收藏
A. Mister B and Book Reading time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces 820B - Mister B and Angle in Polygon
820B - Mister B and Angle in Polygon 思路: 由于正多边形以某个顶点分成的三角形后以这个点为顶点的角都相等,所以可以确定两个点为相邻点,只要再找一个点就够了. 证明 ...
- Codeforces Round #421 (Div. 2)B. Mister B and Angle in Polygon(模拟+精度控制)
传送门 题意 给出正n多边形和一个数a,寻找与a最接近的角,输出角编号 分析 找出多边形上所有角,一一比对即可 trick 1.判断的时候注意精度,i.e.x-eps>0 2.double与do ...
- 【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon
[题目链接]:http://codeforces.com/contest/820/problem/B [题意] 给你一个正n边形; 然后让你在这正n边行中选3个点,组成一个角; 找出角的大小和所给的角 ...
- 【资料下载区】【GMT43相关代码、资料下载地址】更新日期2017/06/28
[GMT43相关文档][更新中...] GMT43原理图(PDF)下载GMT43说明书(PDF)下载GMT43机械结构尺寸(PDF)下载 [GMT43相关例程代码][ARM][更新中...] 基于HA ...
- 团队作业4——第一次项目冲刺(Alpha版本)2017.4.28
2017.04.28 天气晴朗 东风3级. 时间:上午 9:35 ---10:10分 地点:陆大二楼 会议内容:实验室报修系统项目冲刺Alpha版的的最后一天,大家对现在项目的进程进行了讨论,阐述了各 ...
- HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2
/* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...
- HDU 6055 Regular polygon —— 2017 Multi-University Training 2
Regular polygon Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- hdu 6055 : Regular polygon (2017 多校第二场 1011) 【计算几何】
题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[ ...
随机推荐
- ubuntu上mongodb的安装
Ubuntu上安装MongoDB的完全步骤以及注意事项 本文我们详细介绍了Ubuntu上安装MongoDB的全部过程,希望本次的介绍能够对您有所帮助. AD: 2013大数据全球技术峰会课程PPT下载 ...
- c# usercontrol 用户自定义控件无法显示在工具箱的解决办法
由于最开始x86平台,后来换成anyCPU 重新编译也没有删除x86目录下的dll ,也没重新生成 费x86 下的dll , 导致工具箱无法找到目录下的dll 无法加载自定义控件 右击工具栏中的内容选 ...
- taglib简介
在 JSP最佳实践的 上一期,您学习了一种基于scriptlet的技术,这种技术被用来将上次修改的时间戳添加到JavaServer Page(JSP)文件中.不幸的是,比起它所提供的短期利益,scri ...
- Redis单机安装
安装过程 安装环境 ubuntu14.04 server wget http://download.redis.io/releases/redis-3.2.5.tar.gz tar -xzvf ./r ...
- 部分开源gis 方案的比较
3.1MapServer和GeoServer的总体对比 功能上:MapServer弱于GeoServer,QGIS要强于UDIG. 效率上:Mapserver对WMS(Web Map service) ...
- vs2010打开qt的.pro文件时错误解决办法
注意:qt creator工程中一般都已经存在*.pro文件,里面存放着一些自己配置的包含头文件和lib库文的信息,最好不要再重新使用qmake -project生成,若重新生成,则可能要重新增加配置 ...
- 网页定时器setTimeout( )
不斷重複執行的 setTimeout( ) setTimeout( ) 預設只是執行一次, 但我們可以使用一個循環方式, 使到一個setTimeout( ) 再啟動自己一次, 就會使到第二個 setT ...
- Sevlet处理HTML表单
表单<form>用于搜集不同类型的用户输入.可以轻松地将一个HTML表单从一个Servlet发送到浏览器,当用户提交表单时,在表单元素中输入的值就会被当做请求参数发送到服务器. reque ...
- 补课:Shell命令${}
Shell中的${}.##和%%使用范例: 代码如下:file=/dir1/dir2/dir3/my.file.txt可以用${ }分别替换得到不同的值:${file#*/}:删掉第一个 / 及其左边 ...
- C# WebService创建、发布、调用的简单例子
Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布式的互操作的应用程序. Web ...