美文网首页
ACM 之 F - 数论

ACM 之 F - 数论

作者: Gadore千里 | 来源:发表于2016-08-05 20:22 被阅读33次

Description

There is a hill with n holes around. The holes are signed from 0 to n-1. rabit and the wolfrabit and the wolf

A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into is the one signed with 0. Then he will get into the hole every m holes. For example, m=2 and n=6, the wolf will get into the holes which are signed 0,2,4,0. If the rabbit hides in the hole which signed 1,3 or 5, she will survive. So we call these holes the safe holes.

Input

The input starts with a positive integer P which indicates the number of test cases. Then on the following P lines,each line consists 2 positive integer m and n(0<m,n<2147483648).

Output

For each input m n, if safe holes exist, you should output "YES", else output "NO" in a single line.

Sample Input

2
1 2
2 2

Sample Output

NO
YES

理解

代码部分

#include <cstdio>
using namespace std;
int m,n,t,k;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        int x,y,i;
        scanf("%d%d",&m,&n);
        x=m;y=n;
        while(x!=0)
        {
            i=y%x;
            y=x;
            x=i;
        }
        printf("%s\n",y==1?"NO":"YES");
    }
}

意见反馈 || 任何建议

联系我(新浪)
邮箱:qianlizhihao@gmail.com

相关文章

  • ACM 之 F - 数论

    Description There is a hill with n holes around. The hole...

  • 狄利克雷卷积和莫比乌斯反演

    积性函数 定义 一个数论函数f,,有,那么称f为积性函数。一个数论函数f,对于,有 ,那么称f为完全积性函数其中数...

  • 见路不走

    端午回家,只带了一本《初等数论》。老房子还是昏黄的灯光,加上感冒了,头晕晕的,自然没看数论。 躺在床上,打开企鹅f...

  • 动态规划入门

    伟大的acm大神谷哥教我学算法. 引例 斐波那契数 定义一个函数,f(x) = f(x-1) + f(x-2),x...

  • 牛客国庆集训派对Day6(kingdom)

    链接:https://www.nowcoder.com/acm/contest/206/F思路:我们考虑对于一个n...

  • 2020-02-09(学习笔记)

    《数论概论》潘老师 卡米歇尔函数:F(n) = (当n = 时,其中p是奇素数) = 0 = 0 与 关于 p...

  • ACM之开始

    经过激烈的竞争,终于获得免试研究生资格,我最终选择了直博。 在本次资格竞争中,我的加权排名很低,上机考试成绩也不怎...

  • ACM 之 A - The Snail

    Description A snail is at the bottom of a 6-foot well and...

  • ACM 之 A - 递推

    Description 我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分。例如,如果代码中出...

  • 从这里开始

    ACM国际大学生程序设计竞赛 什么是ACM-ICPC? ACM-ICPC全称“ACM International ...

网友评论

      本文标题:ACM 之 F - 数论

      本文链接:https://www.haomeiwen.com/subject/clfksttx.html