【codeforce】几何

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

Input
4 10 4
Output
YES
Input
5 10 4
Output
NO
Input
1 10 10
Output
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;
 } 


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值