HDU_1222_GCD

http://acm.hdu.edu.cn/showproblem.php?pid=1222

 

直接用GCD就可以了,gcd大于1表明每次一周后偏移量为0。

 

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int gcd(int x,int y)
{
    return y?gcd(y,x%y):x;
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int m,n;
        scanf("%d%d",&m,&n);
        if(gcd(m,n) == 1)    printf("NO\n");
        else    printf("YES\n");
    }
    return 0;
}

 

posted @ 2016-10-13 17:24  zzzzzzzzhu  阅读(100)  评论(0编辑  收藏  举报