BC-水题 jrMz and angles

来源:互联网 发布:淘宝模特旺季 编辑:程序博客网 时间:2024/05/16 14:21

Problem Description

jrMz has two types of angles, one type of angle is an interior angle of nn-sided regular polygon, and the other type of angle is an interior angle of mm-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)T(1T10)——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)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
YesYesNo
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.


问题描述
jrMz有两种角,第一种角都是正nn边形的内角,第二种角都是正mm边形的内角。jrMz想选出其中一些,某种角可以选多个或一个都不选,使得选出的所有角的度数之和恰好为360度。jrMz想知道这是否可能实现。
输入描述
有多组测试数据,第一行一个整数\left(1\leq T\leq10\right)(1T10),表示测试数据的组数。对于每组测试数据,仅一行,两个整数n,m\left(3\leq n,m\leq100\right)n,m(3n,m100),之间有一个空格隔开。
输出描述
对于每组测试数据,仅一行,一个字符串,若可能实现则为Yes,若不可能实现则为No。
输入样例
34 83 105 8
输出样例
YesYesNo
Hint
第一组数据中,jrMz可以选择1个第一种角和2个第二种角,因为90+135+135=36090+135+135=360。第二组数据中,jrMz可以选择6个第一种角,因为6\times60=3606×60=360。第三组数据中,jrMz无法选出一些度数之和为360度的角。

#include <iostream>using namespace std;int T;int i,j;int v;int main(){    int  n,m;    cin>>T;    while(T--)    {        v=0;        cin>>n>>m;        for(i=0; i<=n+3; i++)        {            for(j=0; j<=m+3;j++)            {                if((i*(n-2)*180/n+j*(m-2)*180)==360)                    v=1;            }        }        if(v==1)            cout<<"Yes"<<endl;        else cout<<"No"<<endl;    }    return 0;}


内角和定理: 多边形内角和定理n边形的内角的和等于: (n - 2)×180°(n大于等于3且n为整数)




0 0
原创粉丝点击