签到题
时间限制:
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
题意: 半径为R的大圆中是否 可以放置n个半径为r的小圆,且小圆贴着大圆的边缘放置
思路:半径为R的大圆中放置n个小圆 半径为r1,当r1>=r时满足题意,
上面那张图 构造三角形解边长
code:
#include <iostream>
#include <complex>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double pi = 3.1415927;
int main()
{
float d;
double n,R,r;
while(scanf("%lf%lf%lf",&n,&R,&r)!=EOF)
{
if(n==1)
{
if(R+R>=r+r)
printf("YES\n");
else
printf("NO\n");
continue;
}
if(n==2)
{
if((r+r)*2<=R+R)
printf("YES\n");
else
printf("NO\n");
continue;
}
double a=180*1.0/n;
double rr=R*1.0*sin(a/180*pi)/(1+sin(a/180*pi));
if(rr>=r)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}