BC-水题 jrMz and angles

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


问题描述
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。
输入样例
3
4 8
3 10
5 8
输出样例
Yes
Yes
No
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
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会飞的Anthony

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值