jrMz and angles(水题)
jrMz and angles
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1071 Accepted Submission(s): 560
For each test case, the only line contains two integers n,m(1≤n,m≤100) with a white space separated.
4 8
3 10
5 8
In test case 1, jrMz can choose 1 angle which belongs to the first type and 2 angles which belong to the second type, because 90+135+135=360. In test case 2, jrMz can choose 6 angles which belong to the first type, because6\times60=360. In test case 3, jrMz can’t make up an angle of 360 degrees.
import java.util.Scanner;
public class Main {
//(n - 2) * 180/n
private static Scanner cin;
static{
cin = new Scanner(System.in);
}
static double getAng(int x){
return (x - 2.0) * 180.0 / x;
}
static boolean isEqual(double x1, double x2){
if(Math.abs(x1 - x2) < 1e-15){
return true;
}else{
return false;
}
}
static boolean work(int n, int m){
double x1 = getAng(n);
double x2 = getAng(m);
for(int i = 0; i * x1 <= 360.0; i++){
for(int j = 0; i * x1 + j * x2 <= 360.0;j++){
double temp = i * x1 + j * x2;
if(isEqual(temp, 360)){
return true;
}
}
}
return false;
}
public static void main(String[] args) {
int T;
T = cin.nextInt();
while(T-- > 0){
int n = cin.nextInt();
int m = cin.nextInt();
if(work(n, m)){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}
2 seconds
256 megabytes
standard input
standard 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.
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.
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.
The possible arrangement of the plates for the first sample is:

题意:
给定一个大圆的半径 R 以及 n 个小院的半径 r 。
问能否把这 n 个小圆贴着大圆边缘放下。
思路:
2*PI/(2 * a)就好了;注意精度要加上1e-15
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double PI = acos(-1.0); int main(){
int n;
double R, r;
while(~scanf("%d%lf%lf", &n, &R, &r)){
if(n == ){
if(R >= r){
puts("YES");
}else{
puts("NO");
}
continue;
}
if(R == r){
if(n <= )
puts("YES");
else
puts("NO");
continue;
}
double a = asin(1.0 * r/(R - r));
double cnt = 2.0 * PI / ( * a);
cnt += 1e-;
if(n <= cnt){
puts("YES");
}else{
puts("NO");
}
}
return ;
}
jrMz and angles(水题)的更多相关文章
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- BC之jrMz and angles
jrMz and angles Accepts: 594 Submissions: 1198 Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
随机推荐
- ML-DL-各种资源汇总
1.Used Libraries, Datasets, and Models 1.1 Libraries TensorFlow (from Google): https://www.tensorflo ...
- redis+nginx+tomcat故障大全
tomcat+nginx+redis中 redis死掉了???确实是防火墙问题centos7用的firewalldfirewalld默认已经安装并启用了,如果需要nginx可以访问需要执行以下命令:# ...
- Excel数据批量导入到SqlServer的方法
1,以Excel为数据源建立连接导入. 关键点在于Excel的数据要有表头,表头要和数据库表的列名一样.连接字符串中HDR=YES不能省略,也就是第一行是表头的意思.IMEX=1;是把数据都当作字符串 ...
- Django添加防跨站请求伪造中间件
第一步: 在全局设置中打开此中间件: MIDDLEWARE_CLASSES = [ ... 'django.middleware.csrf.CsrfViewMiddleware', ... ] ...
- display:box的兼容写法
.box{ /* display */ display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -o-box; ...
- WebForm发送邮件
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Ne ...
- 【转】Smartphone--Android真机管理平台
背景 最近在工作中发现几个问题: 作为测试人员,在做产品兼容性测试时,发现手上的测试设备总是不够用,但是可能其他同事的设备在闲置着: 作为Android和H5开发人员,如果测试同事发现一个兼容性的bu ...
- [技术选型] Node.js
Nodejs标准的web开发框架Express,可以帮助我们迅速建立web站点,比起PHP的开发效率更高,而且学习曲线更低.非常适合小型网站,个性化网站 NodeJS适合运用在高并发.I/O密集.少量 ...
- 飞机找不到,流量哪去了?记一次移动WAP网关导致的问题
这几天随着客户端一个新版本发布,运维发现CDN的流量猛跌: 话说流量就是金钱,流量就是工资.领导很生气,后果很严重.没什么好说的,赶紧查!一开始怀疑服务端有问题,先受伤的总是我们,当然这也是没错的,因 ...
- Prolog学习:基本概念
上一篇对Prolog有了一个感性的认识,今天介绍下Prolog中一些基本概念,想要用Prolog解决一些实际问题之前必须要先了解它们.这些概念在<七周七语言>这本书中都有介绍,我简单提炼汇 ...