Description
Gerald is setting the New Year table. The table has the form of a circle; its radius equalsR. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equalr. Each plate must be completely inside the table and must touch the edge of the table. Of course, the plates must not intersect, but they can touch each other. Help Gerald determine whether the table is large enough forn plates.
Input
The first line contains three integers n,R and r (1 ≤ n ≤ 100,1 ≤ r, R ≤ 1000) — the number of plates, the radius of the table and the plates' radius.
Output
Print "YES" (without the quotes) if it is possible to placen plates on the table by the rules given above. If it is impossible, print "NO".
Remember, that each plate must touch the edge of the table.
Sample Input
4 10 4
YES
5 10 4
NO
1 10 10
YES
Sample Output
NO
YES
Hint
The possible arrangement of the plates for the first sample is: 小圆挨着大圆,是否可以放下n个
#include<cstdio>
#include<algorithm>
using namespace std;
#define pi acos(-1.0)
#include<cmath>
int main()
{
int n,R,r;
while(~scanf("%d%d%d",&n,&R,&r))
{
if(r>R){
if(n==0) printf("YES\n");
else printf("NO\n");
continue;
}
else if(r==R){
if(n<=1) printf("YES\n");
else printf("NO\n");
continue;
}
else if(4*r>2*R){
if(n<=1) printf("YES\n");
else printf("NO\n");
continue;
}
double m=(2.0*(R-r)*(R-r)-(2.0*r)*(2.0*r))/(2.0*(R-r)*(R-r));
//余弦定理
double a=acos(m);
if((n-2.0*pi/a)<1e-10)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

本文介绍了一种用于确定圆形晚宴桌上能否放置指定数量的小圆盘(代表餐盘)的算法。通过输入圆桌半径及小圆盘的半径,判断是否能在圆桌上放置这些圆盘,并且每个圆盘必须接触圆桌边缘。该算法适用于解决空间布局问题。
1675

被折叠的 条评论
为什么被折叠?



