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
输入
1
4 2 3
输出
1
题目大意:给出一个正n边形和它的边长,给出一个面积L,每次操作:连接每边中点构成一个小正n边形,求几次操作后正n边形面积小于或等于L。
思路:读懂题就感觉有问题,一定有公式在里面。事实证明确实如此,因为是正多边形,所以可以直接使用面积公式:
S=1/4*(r²)*n*tan(1/2θ),然后每次操作后的面积也有公式:操作后的面积与原面积比为:【cos(180°/n)】²(公式证明,看看?)
然后,,,这题就没了.......
代码如下:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;
#define pi acos(-1.0)
int main()
{
int t,k=0,i;
cin>>t;
while(t--)
{
k++;
double n,a,l,b,s;
cin>>n>>a>>l;
b=cos(pi/n)*cos(pi/n);
s=(double)n*a*a/tan(pi/n)/4;
for(i=0;;i++)
{
if(s<=l)
{
cout<<i<<endl;break;
}
s*=b;
}
}
return 0;
}