Codeforces Round #421 B. Mister B and Angle in Polygon
2017-07-20 00:23
387 查看
题目网址: Codeforces Round #421 B. Mister B and Angle in Polygon
思路:正多边形,我们可以知道三个点组成的角度只有N-2个,我们可以求出最小的那个角度即2 1 3,第二小的为2 1 4 ,最大的为 2 1 N
因为边在往顺时针扩大! 画下图就知道了
题意分析:
题意:给出正n边形和一个角度a, 要我们找出三个顶点,使其组成的角度最接近a, 其中点的编号按照顺时针增加思路:正多边形,我们可以知道三个点组成的角度只有N-2个,我们可以求出最小的那个角度即2 1 3,第二小的为2 1 4 ,最大的为 2 1 N
因为边在往顺时针扩大! 画下图就知道了
代码:
#include <iostream> #include <algorithm> using namespace std; int main(int argc, char const *argv[]) { int n, a; while (~scanf("%d %d", &n, &a)) { int ans = 3; double deg = 180.0 * (n - 2) / n; // 最大角度数 double ang = (180 - deg) / 2; // 最小角度数 double tmp; for (int i = 4; i <= n; i++) { tmp = (180.0 - deg) * (i - 2) / 2; // 公式推导可得 if (abs(ang - a) > abs(tmp - a)) { ang = tmp; ans = i; } } printf("2 1 %d\n", ans); } return 0; }
相关文章推荐
- Codeforces Round 421 Div.2 D. Mister B and PR Shifts 思维 乱搞
- Codeforces Round #421 (Div. 1):B. Mister B and PR Shifts 思维,乱搞
- Codeforces Round #421 (Div. 1):B. Mister B and PR Shifts(瞎搞)
- 【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon
- Codeforces #Round 447Div2 D - Ralph And His Tour in Binary Country
- CF820B-Mister B and Angle in Polygon
- Codeforces Round #389 (Div. 2)A. Santa Claus and a Place in a Class(水题)
- CF820B:Mister B and Angle in Polygon(数学 & 几何)
- Codeforces Round #447 (Div. 2) D. Ralph And His Tour in Binary Country(dfs)
- Codeforces Round #189 (Div. 1) Kalila and Dimna in the Logging Industry 斜率DP
- Codeforces Round #421 (Div. 2) | B. Mister B and Angle in Polygon
- codeforces Round 447 div2 D Ralph And His Tour in Binary Country
- Codeforces Round #421 (Div. 2) B. Mister B and Angle in Polygon
- Codeforces#421 Mister B and Angle in Polygon
- Codeforces Round #421 A. Mister B and Book Reading
- Codeforces Round #404 (Div. 2) D. Anton and School - 2
- Codeforces Round #384 B. Chloe and the sequence
- 【Codeforces Round 262 (Div 2)A】【水题】Vasya and Socks 妈妈买袜子 最多穿几天
- Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation 贪心
- Codeforces Round #371 (Div. 2) C. Sonya and Queries (map)