【杭电】5660正多边形

C - C
Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

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\left(1\leq T\leq10\right)$――The number of the test cases.
For each test case, the only line contains two integers $n,m\left(1\leq n,m\leq100\right)$ 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的角
     暴力枚举
code:
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int t,n,m;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&n,&m);
		double a=180*1.0*(n-2)/n;
		double b=180*1.0*(m-2)/m;
		bool faut=false;
		for(int i=0;i<=8;i++)
		{
			for(int j=0;j<=8;j++)
			if(a*i+b*j==360.0){
				faut=true;break;
			}
		}
		if(faut) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值