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. JDBC-批处理操作

    javaweb学习总结(三十六)——使用JDBC进行批处理 在实际的项目开发中,有时候需要向数据库发送一批SQL语句执行,这时应避免向数据库一条条的发送执行,而应采用JDBC的批处理机制,以提升执行效 ...

  2. WebRTC网关服务器单端口方案实现

    标准WebRTC连接建立流程 这里描述的是Trickle ICE过程,并且省略了通话发起与接受的信令部分.流程如下: 1) WebRTC A通过Signal Server转发SDP OFFER到Web ...

  3. 配置文件报错:不允许有匹配 [xX][mM][lL] 的处理指令目标。

    http://www.68idc.cn/help/buildlang/ask/20150108163110.html ————————————————————————————————————————— ...

  4. Spring MVC异常处理SimpleMappingExceptionResolver

    Spring MVC异常处理SimpleMappingExceptionResolver[转] (2012-12-07 13:45:33) 转载▼ 标签: 杂谈 分类: 技术分享 Spring3.0中 ...

  5. ES6之函数参数

    ES6中对于函数参数主要增加了以下内容: 1.参数的扩展/数组的展开: 2.默认参数. 什么是参数的扩展? 看下面代码: <!DOCTYPE html> <html lang=&qu ...

  6. JavaScript开源跨平台框架NativeScript

    NativeScript是一款使用JavaScript语言来构建跨平台原生移动应用的开源框架,支持iOS.Android和Windows Phone.且NativeScript的使用没有过多繁杂的要求 ...

  7. [hadoop读书笔记] 第一章 初识 Hadoop

    P3-P4: 目前遇见的问题很简单:硬盘容量不断提升,1TB的已成为主流,然而数据传输速度从1990年的4.4MB/s仅上升到当前约100MB/s 读取一个1TB的硬盘数据需要耗时至少2.5个小时.写 ...

  8. USB2.0学习笔记连载(四):安装Cypress官网套件

    上一篇博客大概讲了一下USB通用驱动程序的解析.笔者使用Cypress官网给定的资料去完成USB驱动开发.官网资料地址:http://www.cypress.com/?rID=14321 下载如下图的 ...

  9. OpenStack配置解析库oslo.config的使用方法

    OpenStack的oslo项目旨在独立出系统中可重用的基础功能,oslo.config就是其中一个被广泛使用的库,该项工作的主要目的就是解析OpenStack中命令行(CLI)或配置文件(.conf ...

  10. Windows的VNC客户端连接Linux无法复制粘贴

    问题描述 在Windows里使用VNC客户端远程桌面连接Linux,Linux里的文字信息复制之后无法粘贴到Windows中 解决办法 在Linux中执行命令 vncconfig -nowin& ...