签到题 nyoj 1234 ,题目链接 click here
签到题
时间限制:1000 ms | 内存限制:65535 KB
难度:2
描述
hrw最近看到一个有趣的几何题,题目描述是这样的:一个大圆盘里面放入许多小圆盘,每个小圆盘必须接触大圆盘边缘且与其他小圆盘不能相交,但它们可以互相接触,每个小圆盘具有相同的半径,求此条件下能否放入n个小圆盘。

输入
Multiple sets of test data,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.and you can think the pi is 3.1415927
输出
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.
样例输入
4 10 4
2 10 10
样例输出
YES
NO
#include<stdio.h>
#include<math.h>
int main()
{
int R,r,n;
double pi = 3.141592653 ;
while(~scanf("%d%d%d",&n,&R,&r))
{
if(n==1&&r<=R)
{
printf("YES\n");
continue;
}
double x=1.0*r/(R-r);
double a = asin(x)*180.0/pi;
a=a*2.0*n-0.0000001;//精度问题;
if(a<=360.00000000000)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
本文介绍了一道关于在大圆盘内放置多个小圆盘的几何问题,通过数学计算判断是否能在不相交的情况下放置指定数量的小圆盘,并提供了一个C语言实现的解决方案。
724

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



