joj2343

 2343: Sing a Song


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE
3s 16384K 1186 215 Standard

N students are playing a game, they sit in a circle and number themselves with 1 to N clockwise. First, the teacher let the student whose number is 1 to sing a song. Then Mth student clockwise sings a song, and go on. + 0 1 what to know whether each student has a chance to sing.Can you help him?

Input

The input file consists several cases. Each case contains two positive integers N and M. (1 <= n, m <=1000)

Hint: Use "scanf" and "printf" to read and write.

Output

If everyone has a chance to sing, print "YES", else "NO";

Sample Input

5 1
4 2

Sample Output

YES
NO

Problem Source: +01


This problem is used for contest: 57  190 







#include<stdio.h>
int gcd(int u,int v)
{
    while(u%v!=0)
    {
        int t=u%v;
        u=v;
        v=t;
    }
    return v;
}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2)
    {
        if(gcd(n,m)!=1)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}
这个题目可以用推到的方式解决,如果mn有大于一的共因数那么他们就可以避开与他们相邻的数了。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值