CodeForces - 140A New Year Table (几何题)当时没想出来-----补题
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:
画画图就好做了,当时没做出来。
每个小圆所占的圆心角都是可以计算的,由角度可以计算最多的圆是多少个,和给定的值比较就可以了。
#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;
}
写在最后: 我叫风骨散人,名字的意思是我多想可以不低头的自由生活,可现实却不是这样。家境贫寒,总得向这个世界低头,所以我一直在奋斗,想改变我的命运给亲人好的生活,希望同样被生活绑架的你可以通过自己的努力改变现状,深知成年人的世界里没有容易二字。目前是一名在校大学生,预计考研,热爱编程,热爱技术,喜欢分享,知识无界,希望我的分享可以帮到你! 如果有什么想看的,可以私信我,如果在能力范围内,我会发布相应的博文! 感谢大家的阅读!?你的点赞、收藏、关注是对我最大的鼓励!
- AI—未来医疗
- 微信小程序新功能上线 一键连Wi-Fi手机变门禁卡
- 使用xUnit为.net core程序进行单元测试(中)
- Asp.Net 用Jquery和一般处理程序实现无刷新上传大文件
- WCF技术剖析之十五:数据契约代理(DataContractSurrogate)在序列化中的作用
- WCF技术剖析之十四:泛型数据契约和集合数据契约(上篇)
- WCF技术剖析之十四:泛型数据契约和集合数据契约(下篇)
- WCF技术剖析(卷1)之前言
- WCF技术剖析(卷1)之目录
- WCF技术剖析(卷1)之推荐序
- 谈谈基于SQL Server 的Exception Handling[上篇]
- 谈谈WCF中的Data Contract(4):WCF Data Contract Versioning
- 如何在silverlihgt中使用右键
- WCF技术剖析之十二:数据契约(Data Contract)和数据契约序列化器(DataContractSerializer)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- python pickle模块
- 吴恩达机器学习笔记18-逆矩阵、矩阵转置
- Tkinter messagebox弹窗
- 'utf-8' codec can't decode byte 0xff in position 0
- iOS今日头条第3轮面试回忆
- Python:os.path.join()产生的斜杠在Windows和Linux下的不同表现和解决方法
- python 深复制和浅复制详解
- Octave入门之数据操作—ML Note28
- matlab导出csv文件多种方法实现
- matlab面向对象编程基础
- Octave数据运算基础教程-ML Note29
- Octave中数据的可视化—ML Note 30
- matplotlib animation FuncAnimation画2D线图
- 坚持一下只需要一个理由就够了
- IGD反转世代距离-多目标优化评价指标概念及实现