B. Mister B and Angle in Polygon 421.div2
来源:互联网 发布:ipad的蜂窝移动数据 编辑:程序博客网 时间:2024/04/30 10:53
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变形,确定一定由三个不同定点构成的角,是的这个角-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;}
水波。
- B. Mister B and Angle in Polygon 421.div2
- CF820B-Mister B and Angle in Polygon
- codeforces820B Mister B and Angle in Polygon
- Codeforces 820B Mister B and Angle in Polygon
- CF #421 B. Mister B and Angle in Polygon
- codeforces 820B Mister B and Angle in Polygon
- CodeForces 820B Mister B and Angle in Polygon
- Codeforces Round #421 B. Mister B and Angle in Polygon
- Codeforces#421 Mister B and Angle in Polygon
- CF820B:Mister B and Angle in Polygon(数学 & 几何)
- Codeforces Round #421 (Div. 2) B. Mister B and Angle in Polygon
- Codeforces Round #421 (Div. 2) | B. Mister B and Angle in Polygon
- #421 Div.2 B. Mister B and Angle in Polygon——几何数学
- Mister B and Book Reading
- Mister B and Book Reading
- CF820A-Mister B and Book Reading
- Codeforces820A Mister B and Book Reading
- A. Mister B and Book Reading
- MySql绿色安装方法
- API--String
- HTML+CSS编写静态网站-19 课后作业04
- C++初始化列表时,为什么不能直接在构造函数中输出
- 通过BrowserMob Proxy获取网站network请求
- B. Mister B and Angle in Polygon 421.div2
- 字符串方法之练习
- Centos7快速安装haproxy
- 09-rabbitmq-消息主题-spring
- 手机号码段简介以及最新手机号段归属地数据库(2017年6月28日)
- vim编辑二进制文件
- BZOJ 4519 [Cqoi2016]不同的最小割 最小割树(分治最小割)
- base64编码详解
- yii2下action下直接返回图片给浏览器