• BC之jrMz and angles



    jrMz and angles

     
     Accepts: 594
     
     Submissions: 1198
     Time Limit: 2000/1000 MS (Java/Others)
     
     Memory Limit: 65536/65536 K (Java/Others)
    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 Tleft(1leq Tleq10 ight)T(1T10)——The number of the test cases. For each test case, the only line contains two integers n,mleft(1leq n,mleq100 ight)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 imes60=360. In test case 3, jrMz can’t make up an angle of 360 degrees.

    大水体,直接试一下就行了。。。

    官方解:

    不妨令nleq mnm

    如果n>6n>6,由于所有角都大于120度且小于180度,也就是说,两个角一定不够,而三个角一定过多。因此一定无解;

    nleq6n6时,如果n=3n=3n=4n=4n=6n=6,那么显然只需要正nn边形的角就可以了。如果n=5n=5,则已经有一个108度的角。若这种角:不取,则显然仅当m=6m=6时有解;取1个,则还差360-108=252360108=252(度),但是没有一个正mm边形的内角的度数是252的约数;取2个,则还差360-108 imes2=144360108×2=144(度),这恰好是正10边形的内角,取3个,则还差360-108 imes3=36360108×3=36(度),也不可能满足;取大于3个也显然不可能。

    因此得到结论:当nnmm中至少有一个为3或4或6时,或者当nnmm中一个等于5另一个等于10时,有解,否则无解,时间复杂度为

    Oleft(T ight)O(T)


    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<queue>
    #include<stack>
    #include<string>
    #include<map>
    #include<set>
    #include<ctime>
    #define eps 1e-6
    #define MAX 100005
    #define INF 0x3f3f3f3f
    #define LL long long
    #define pii pair<string,int>
    #define rd(x) scanf("%d",&x)
    #define rd2(x,y) scanf("%d%d",&x,&y)
    const int dir[][2] = { {-1, 0}, {0, -1}, { 1, 0 }, { 0, 1 } };
    using namespace std;
    int gcd (int a,int b){
    
     int temp;
     while(a/b!=0){
        temp=a;
        a=b;
        b=a%b;
     }
     return b;
    }
    
    int main()
    {
        int T;
        int a ,b;
        scanf("%d",&T);
        while(T--)
        {
          rd2(a,b);
          int mark=0;
          int zi1=(a-2)*b,zi2=(b-2)*a;
          int mu = a*b;
          for(int i=0;i<=10;i++)
          for(int j=0;j<=10;j++){
            if((zi1*i+zi2*j)%(a*b)==0&&(zi1*i+zi2*j)/(a*b)==2)
                mark=1,i=10,j=10;
            //cout<<"ssssssssss"<<endl;
          }
          if(mark)
            printf("Yes
    ");
          else
            printf("No
    ");
        }
        return 0;
    }



  • 相关阅读:
    搭建ARL资产安全灯塔
    免杀技术发展史
    米酷CMS 7.0.4代码审计
    腾讯安全实习 应用运维安全面试
    Docker部署CTF综合性靶场,定时刷新环境
    西湖论剑2020MISC-Yusa_yyds
    (转)马云炮轰银行监管的解读
    ATT&CK 实战
    Docker环境复现利用Redis未授权访问漏洞 >> 批量扫描检测利用
    修改CH340芯片信息
  • 原文地址:https://www.cnblogs.com/zswbky/p/6718020.html
Copyright © 2020-2023  润新知