链接:https://ac.nowcoder.com/acm/contest/163/D
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
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边形的面积公式,S=n*r*r*sin(2*Pi/n)/2(n个三角形的面积),r=a/sin(Pi/n)/2;(a是正n边形的边长)。可以看到当把每个边的中点连接之后的新n边形的面积与r有关。其中r1=r*cos(PI / n)*cos(PI / n)。
#include<iostream>
#include<math.h>
#define PI 3.1415926
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, a, l; int ans = 0;
scanf("%d%d%d", &n, &a, &l);
double r = a / sin(PI / n) / 2;
double s = n*r*r*sin(2 * PI / n) / 2;
while (s>l)
{
s *= cos(PI / n)*cos(PI / n);
ans++;
}
printf("%d\n", ans);
}
return 0;
}