hdu 5660 jrMz and angles(水题)

来源:互联网 发布:微信有变声软件吗 编辑:程序博客网 时间:2024/05/17 07:32
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(1T10)——The number of the test cases.
For each test case, the only line contains two integers n,m(1n,m100) with a white space separated.
 

Output
For each test case, the only line contains a integer that is the answer.
 

Sample Input
34 83 105 8
 

Sample Output
YesYes

No

solution:

给你两个正多边形的边数,问你这两个正多边形内角的组合能否组成360,小模拟。

#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<map>#include<queue>#include<stack>#include<string>#include<iostream>#include<set>using namespace std;typedef long long ll;#define mem(a) (memset(a,0,sizeof(a)))#define f0(x,n) for(int x=0;x<n;x++)#define f1(x,n) for(int x=1;x<=n;x++)#define si(x) scanf("%d",&x)#define sii(x,y) scanf("%d%d",&x,&y)#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)#define sl(x) scanf("%I64d",&x)#define sll(x,y) scanf("%I64D%I64d",&x,&y)#define sd(x) scanf("%lf",&x)#define sdd(x,y) scanf("%lf%lf",&x,&y)#define mp(x,y) make_pair(x,y)#define pb(x) push_back(x)const int maxn = 1e6 + 500;const int inf = 1e9 + 7;int n,m;int main(){    int t;    si(t);    while (t--)    {        scanf("%d%d", &n, &m);        n = 180 * (n - 2) / n, m = 180 * (m - 2) / m;        int f = 0;        if (360 % n == 0 || 360 % m == 0)f = 1;        else {            int ans = 360;            while (ans >= n)            {                ans -= m;                if (ans%n == 0){ f = 1; break; }            }        }        if (f)printf("Yes\n");        else printf("No\n");    }    return 0;}


0 0
原创粉丝点击