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

Problem Description
jrMz has two types of angles, one type of angle is an interior angle of n-sided regular polygon, and the other type of angle is an interior angle of m-sided regular polygon. jrMz wants to use them to make up an angle of 360 degrees, which means, jrMz needs to choose some or none of the angles which belong to the first type and some or none of the angles which belong to the second type so that the sum value of the angles chosen equals 360 degrees. But jrMz doesn’t know whether it is possible, can you help him?
 
Input
The first line contains an integer T(1≤T≤10)——The number of the test cases.
For each test case, the only line contains two integers n,m(1≤n,m≤100) with a white space separated.
 
Output
For each test case, the only line contains a integer that is the answer.
 
Sample Input
3
4 8
3 10
5 8
 
Sample Output
Yes Yes No

Hint

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.

题解:给两个正n,m边形,选角度凑成360度,每个角度是(n - 2)*180/n
代码:
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");
}
}
}
}
A. New Year Table
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

The first line contains three integers nR 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
input
output
input
output
input
output
Note

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(水题)的更多相关文章

  1. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [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 ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. BC之jrMz and angles

    jrMz and angles  Accepts: 594  Submissions: 1198  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  9. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

随机推荐

  1. 三篇文章了解 TiDB 技术内幕——说存储

    数据库.操作系统和编译器并称为三大系统,可以说是整个计算机软件的基石.其中数据库更靠近应用层,是很多业务的支撑.这一领域经过了几十年的发展,不断的有新的进展. 很多人用过数据库,但是很少有人实现过一个 ...

  2. 微信小程序——navigator无法跳转

    今天在做小程序的时候,发现用navigator无法进行跳转.url 路径也是对的. 后面发现是因为我需要跳转的页面定义在了tabBar里面的.如下图: 如果需要跳转到tabBar里面定义的这些页面,需 ...

  3. Python 匿名参数

    #-*- coding:utf-8 -*- #匿名函数 #匿名函数语法格式 ''' 变量 = lambda 参数列表:表达式 ''' func = lambda x,y:x+y a = func(2, ...

  4. Python 引用

    python引用python中的数值类型变量也是引用,例如: a = 100b=a那么a和b指向同一块内存但是当修改a或者b的值得时候,Python会新分配一块内存来存储新的值 python中不可变类 ...

  5. 9、Qt 事件处理机制

    原文地址:http://mobile.51cto.com/symbian-272812.htm 在Qt中,事件被封装成一个个对象,所有的事件均继承自抽象类QEvent. 接下来依次谈谈Qt中有谁来产生 ...

  6. chrome误删了bookmarks且已经同步清空了google云端的挽救方式

    收藏夹里被误删文件恢复步骤:1.快捷键 Win+R 输入 Chrome 的用户数据路径:Windows XP:%USERPROFILE%\Local Settings\Application Data ...

  7. Java数据通讯中使用Googgle Protobuf 序列化与反序列化

    概念 1.什么是protocol buffer ProtocolBuffer是用于结构化数据串行化的灵活.高效.自动的方法,有如XML,不过它更小.更快.也更简单.你可以定义自己的数据结构,然后使用代 ...

  8. 【Python】Centos + gunicorn+flask 报错ImportError: No module named request

    今天用Python去下载图片,用到了 urllib.request,这个是python3的方法.python2 使用的是urllib2 遇到了这么个问题后台报错,ImportError: No mod ...

  9. elasticsearch系列五:搜索详解(查询建议介绍、Suggester 介绍)

    一.查询建议介绍 1. 查询建议是什么? 查询建议,为用户提供良好的使用体验.主要包括: 拼写检查: 自动建议查询词(自动补全) 拼写检查如图: 自动建议查询词(自动补全): 2. ES中查询建议的A ...

  10. Solr系列一:Solr(Solr介绍、Solr应用架构、Solr安装使用)

    一.前言 前面已经学习了Lucene的分词.索引详解.搜索详解的知识,已经知道开发一个搜索引擎的流程了.现在就会有这样的一个问题:如果其他的系统也需要使用开发的搜索引擎怎么办呢?这个时候就需要把开发的 ...