简单计算几何+卡精度 New Year Table CodeForces - 140A

xiaoxiao2021-02-28  157

链接:https://cn.vjudge.net/contest/166560#problem/D 注意题目中小圆一定贴着边放

Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. 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 equal r. 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 for n 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 place n 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.

Example Input 4 10 4 Output YES Input 5 10 4 Output NO Input 1 10 10 Output YES Note The possible arrangement of the plates for the first sample is:

代码+注释:

#include <iostream> #include<algorithm> #include<cmath> #include<cstdio> using namespace std; int main() { double n,R,r; cin>>n>>R>>r; double t,tt; // printf("%lf",t); if(r>R) //小圆大于大圆肯定不成立 printf("NO\n"); else if(2*r>R)//否则小圆半径大于大圆半径一半 { if(n==1)//只能放下一个 printf("YES\n"); else printf("NO\n"); } else //只在r<R/2时成立,注意适用条件 { tt = r/(R-r); //算圆心角R圆心与小圆边界连线相切可得垂直 t = asin(tt); double pi = asin(1)*2; //π的标准写法 // printf("%.30lf\n",pi); if(n*t<pi || n*t-pi<1e-10) //小于或等于 { printf("YES\n"); } else printf("NO\n"); } return 0; }
转载请注明原文地址: https://www.6miu.com/read-27970.html

最新回复(0)