NN and the Optical Illusion-光学幻觉 CodeForce1100C 几何

题目链接:NN and the Optical Illusion

题目原文

NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:

It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.

He managed to calculate the number of outer circles 𝑛n and the radius of the inner circle 𝑟r. NN thinks that, using this information, you can exactly determine the radius of the outer circles 𝑅R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.

Help NN find the required radius for building the required picture. 

题目大意

上面的图,其实中间的两个圆的面积是相等的。要做的是已知中间的圆的半径r,如果外面有n个圆围着中间的圆,求外围圆的半径。

思路

注意一下输出的时候的小数位数即可。

cout默认输出是6位,所以用printf或者设置一下输出精度

题解

 1 #include <iostream>
 2 #include <cmath>
 3 #include <cstdio>
 4 
 5 using namespace std;
 6 
 7 
 8 const double PI=acos((double)-1);
 9 int num, r;
10 
11 int main(int argc, char const *argv[])
12 {
13 
14     cin >> num >> r;
15     double sin_ = sin(PI/num);
16     double ans = r*(sin_ / (1-sin_));
17     printf("%.7f", ans);
18     return 0;
19 }

 

posted @ 2019-02-17 22:33  SaltyFishQF  阅读(255)  评论(0编辑  收藏  举报