Problem Description
There is a hill with n holes around. The holes are signed from 0 to n-1.

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
 
Author
weigang Lee
 
Source
 
Recommend
Ignatius.L
 #include <stdio.h>
#include <math.h>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int gcd(int a,int b){
return b==?a:gcd(b,a%b);
}
int main()
{
int n,m,t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
if(gcd(n,m)==){
printf("NO\n");
}
else{
printf("YES\n");
}
}
return ;
}

GCD(1222)Wolf and Rabbit的更多相关文章

  1. iOS多线程开发之GCD(中篇)

    前文回顾: 上篇博客讲到GCD的实现是由队列和任务两部分组成,其中获取队列的方式有两种,第一种是通过GCD的API的dispatch_queue_create函数生成Dispatch Queue:第二 ...

  2. 求gcd(最大公因数),lcm(最小公倍数)模板

    gcd(最大公因数),lcm(最小公倍数) #include<iostream> using namespace std; int gcd(int a,int b)//辗转相除法(欧几里德 ...

  3. ios专题 - GCD(1)

    什么是GCD? Grand Central Dispatch或者GCD,是一套低层API,提供了一种新的方法来进行并发程序编写.从基本功能上讲,GCD有点像 NSOperationQueue,他们都允 ...

  4. iOS多线程开发之离不开的GCD(上篇)

    一.GCD基本概念 GCD 全称Grand Central Dispatch(大中枢队列调度),是一套低层API,提供了⼀种新的方法来进⾏并发程序编写.从基本功能上讲,GCD有点像NSOperatio ...

  5. 深入GCD(一): 基本概念和Dispatch Queue

    什么是GCD?Grand Central Dispatch或者GCD,是一套低层API,提供了一种新的方法来进行并发程序编写.从基本功能上讲,GCD有点像NSOperationQueue,他们都允许程 ...

  6. 【BZOJ】2820: YY的GCD(莫比乌斯)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2820 此题非常神! 下文中均默认n<m 首先根据bzoj1101的推理,我们易得对于一个数d使 ...

  7. ios专题 - GCD(2)

    何为Dispatch Sources 简单来说,dispatch source是一个监视某些类型事件的对象.当这些事件发生时,它自动将一个block放入一个dispatch queue的执行例程中. ...

  8. 多线程编程 - GCD(转)

    原文:http://blog.csdn.net/q199109106q/article/details/8566300 一.简介 在iOS所有实现多线程的方案中,GCD应该是最有魅力的,因为GCD本身 ...

  9. 2018.06.29 NOIP模拟 Gcd(容斥原理)

    Gcd 题目背景 SOURCE:NOIP2015-SHY-2 题目描述 给出n个正整数,放入数组 a 里. 问有多少组方案,使得我从 n 个数里取出一个子集,这个子集的 gcd 不为 1 ,然后我再从 ...

随机推荐

  1. 2015广东工业大学ACM学校巡回赛 I 游戏高手 (如压力dp)

    Problem I: 游戏王 Description 小学的时候,Stubird很喜欢玩游戏王.有一天,他发现了一个绝佳的连锁组合,这个连锁组合须要6张卡. 但是他一张都没有,但是他的那些朋友们有.只 ...

  2. chrome(转)

    阅读目录 Chrome的隐身模式 Chrome下各种组合键 Chrome的about指令 chrome://accessibility     查看浏览器当前访问的标签 chrome://appcac ...

  3. 4.锁定--Java的LockSupport.park()实现分析

    LockSupport类是Java6(JSR166-JUC)引入的一个类,提供了主要的线程同步原语. LockSupport实际上是调用了Unsafe类里的函数.归结到Unsafe里,仅仅有两个函数: ...

  4. Zen Coding css,html缩写替换大观 快速写出html,css

    阅读本文,先仔细阅读网站文章. Zen Coding 快速编写HTML/CSS代码的实现 复制代码 代码如下:E 元素名称(div, p); E#id 使用id的元素(div#content, p#i ...

  5. 【Android进阶】URL与URI的区别

    首先,URI,是uniform resource identifier,统一资源标识符,用来唯一的标识一个资源. 而URL是uniform resource locator,统一资源定位器,它是一种具 ...

  6. Linux lspci查看硬件设备

    Linux 主机的硬件配备 lspci 找到的是眼下主机上面的硬件配备 [root@www ~]# lspci [-vvn] 选项与參数: -v     :显示很多其它的 PCI 接口装置的具体信息 ...

  7. OpenCVR 有新成员 OpenCVV OpenCVC

    OpenCVC主要负责OpenCVR报名, OpenCVV支持Android IOS Mac Windows 的client 版权声明:本文博客原创文章,博客,未经同意,不得转载.

  8. ZOJ 3820 Building Fire Stations

    题意: 树上找两个点  使得其它点到这两点随意一点的距离的最大值最小 思路: 最大值最小  想到二分  在二分的基础上判定这个最大值是否可能 怎样判定这个问题就是怎样选那两个点的问题  非常明显  我 ...

  9. 初步swift语言学习笔记8(保留了很多OC实现)

    笔者:fengsh998 原文地址:http://blog.csdn.net/fengsh998/article/details/32715833 转载请注明出处 假设认为文章对你有所帮助,请通过留言 ...

  10. bash no such file or directory in ubuntu 1404

    我在我的今天macbook pro retina 里面安装的虚拟机ubuntu 1404. 当我试图执行cadence ncverilog时间.ubuntu终端错误"bash no such ...