前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CodeForces - 140A New Year Table (几何题)当时没想出来-----补题

CodeForces - 140A New Year Table (几何题)当时没想出来-----补题

作者头像
风骨散人Chiam
发布2020-10-28 09:40:53
5300
发布2020-10-28 09:40:53
举报
文章被收录于专栏:CSDN旧文CSDN旧文

A. New Year Table time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 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.

Examples inputCopy 4 10 4 outputCopy YES inputCopy 5 10 4 outputCopy NO inputCopy 1 10 10 outputCopy YES Note The possible arrangement of the plates for the first sample is:

在这里插入图片描述
在这里插入图片描述

画画图就好做了,当时没做出来。

在这里插入图片描述
在这里插入图片描述

每个小圆所占的圆心角都是可以计算的,由角度可以计算最多的圆是多少个,和给定的值比较就可以了。

代码语言:javascript
复制
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
const double PI=acos(-1.0);
int main()
{
	int n,R,r;
	cin>>n>>R>>r;
	if(r>R)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	else if(r>(R-r))
	{
		if(n==1)cout<<"YES"<<endl;
		else  cout<<"NO"<<endl;
		return 0;
	}
	double agle=asin((double)r/(double)(R-r));  //计算角度
	if(2.0*PI-2.0*agle*n>=-1e-12)  //精度是真高
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

写在最后: 我叫风骨散人,名字的意思是我多想可以不低头的自由生活,可现实却不是这样。家境贫寒,总得向这个世界低头,所以我一直在奋斗,想改变我的命运给亲人好的生活,希望同样被生活绑架的你可以通过自己的努力改变现状,深知成年人的世界里没有容易二字。目前是一名在校大学生,预计考研,热爱编程,热爱技术,喜欢分享,知识无界,希望我的分享可以帮到你! 如果有什么想看的,可以私信我,如果在能力范围内,我会发布相应的博文! 感谢大家的阅读!?你的点赞、收藏、关注是对我最大的鼓励!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-06-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档