题目描述
In order to become a magical girl, Thinking-Bear are learning magic circle. He first drew a regular polygon of N sides, and the length of each side is a. He want to get a regular polygon of N sides, and the polygon area is no more than L. He doesn't want to draw a new regular polygon as it takes too much effort. So he think a good idea, connect the midpoint of each edge and get a new regular polygon of N sides. How many operations does it need to get the polygon he want?
输入描述:
The first line of the input is T(1≤ T ≤ 100), which stands for the number of test cases you need to solve. The first line of each case contains three space-separated integers N, a and L (3 ≤ N ≤ 10, 1 ≤ a ≤ 100, 1 ≤ L ≤ 1000).
输出描述:
For each test case, output a single integer.
示例1
输入
14 2 3
输出
1 思路:弱弱的推了一半天,在大佬的指点之下终于推出了公式;题意是讲若当前多边形的面积大于L就将每条边的中点依次连接构成一个新的多边形 求多少次这种操作之后面积S不大于L;首先已知多边形边长为a,外接圆半径R = a/(2*sin(pi/n)); 面积S = 0.5*n*R^2*sin((2*pi)/n); 然后以此类推求出内接正多边形的边长与内接正多变形的外接圆半径r;内接正多变的边长x = a*cos(pi/n);emmmmm就以此类推下去了吧下面附上代码
1 #include2 #include 3 #define pi 3.141592653589793238462643383 4 using namespace std; 5 6 int T,n; 7 double a,L; 8 int main() 9 {10 ios::sync_with_stdio(false);11 cin>>T;12 while(T--){13 cin>>n>>a>>L;14 double R = a/(2.0*sin(pi/n));15 double s = 0.5*n*R*R*sin((2*pi)/n);16 double r;int ans = 0;17 while(s>L){18 ans++;19 a = a*cos(pi/n);20 r = a/(2.0*sin(pi/n));21 s = 0.5*n*r*r*sin((2*pi)/n);22 }23 cout< <