CodeForces - 140A New Year Table (数学几何&精度)大圆内能放几个小圆

CodeForces - 140A
Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u

Status

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

Hint

The possible arrangement of the plates for the first sample is:

Source

//题意:输入n,R,r
表示给你一个半径为R的大圆,问沿着大圆的边界放不相交(可以相切)的半径为r的小圆,问是否可以放n个。
//思路:
通过求圆心角大小来求最多可以放几个小圆(画个图模拟一下就可以理解了),加上几个特判就过了,然后就是精度问题(1e-9的精度)。
#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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值