Time Limit: 2000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
Hint
The possible arrangement of the plates for the first sample is:
Source
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#define PI acos(-1.0)
using namespace std;
int main()
{
int n;
double r,R;
while(scanf("%d%lf%lf",&n,&R,&r)!=EOF)
{
int k=0;
double l1,l2,l3;
double y,x1;
if(R<r)
printf("NO\n");
else if(R<2*r)
{
if(n==1)
printf("YES\n");
else
printf("NO\n");
}
else if(R==2*r)
{
if(n<=2)
printf("YES\n");
else
printf("NO\n");
}
else
{
l1=R-r;l2=r;l3=sqrt(l1*l1-l2*l2);
y=(l1*l1+l3*l3-l2*l2)/(2*l1*l3);
x1=acos(y);
k+=(PI+0.000000001)/x1;
if(k<n)
printf("NO\n");
else
printf("YES\n");
}
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#define PI acos(-1.0)
using namespace std;
int main()
{
int n;
double r,R;
while(scanf("%d%lf%lf",&n,&R,&r)!=EOF)
{
int k=0;
double l1,l2,l3;
double y,x1;
if(R<r)
printf("NO\n");
else if(R<2*r)
{
if(n==1)
printf("YES\n");
else
printf("NO\n");
}
else if(R==2*r)
{
if(n<=2)
printf("YES\n");
else
printf("NO\n");
}
else if(R==3*r)//这块是刚开始时不知是精度问题,加的一个特判,没想到过了(就那一组卡到了1e-9的精度),然后根据这组数据推出的这是个精度问题)
{
if(n<=6)
printf("YES\n");
else
printf("NO\n");
}
else
{
l1=R-r;l2=r;l3=sqrt(l1*l1-l2*l2);
y=(l1*l1+l3*l3-l2*l2)/(2*l1*l3);
x1=acos(y);
k+=PI/x1;
if(k<n)
printf("NO\n");
else
printf("YES\n");
}
}
return 0;
}