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. ASF(传感器)

    版权声明:曾经的Blog文章合并.原创作品,谢绝转载.否则将追究法律责任. SensorManager类:用于创建sensor service的实例.该类提供了非常多 用于訪问和枚举传感器,注冊和注销 ...

  2. CopyOnWriteArrayList源代码阅读器

    java.util.concurrent在相应的并发集合的包中定义的通用集合类,为了有效地处理并发场景.间CopyOnWriteArrayList它是合适ArrayList.顾名思义CopyOnWri ...

  3. Lua 数据库访问(转)

    本文主要为大家介绍 Lua 数据库的操作库:LuaSQL.他是开源的,支持的数据库有:ODBC, ADO, Oracle, MySQL, SQLite 和 PostgreSQL. 本文为大家介绍MyS ...

  4. 设计模式C++达到 1.辛格尔顿

    实现类的单个案件的Singleton模式.该系统有一个类只有一个实例,而本实施例是容易的外部访问.所以容易控制的实例的数量,并且节省系统资源. 单的情况下通常与一些非本地静态对象的使用,对于这些对象, ...

  5. Java知多少(87)选择框和单选按钮(转)

    选择框.单选框和单选按钮都是选择组件,选择组件有两种状态,一种是选中(on),另一种是未选中(off),它们提供一种简单的 “on/off”选择功能,让用户在一组选择项目中作选择. 选择框 选择框(J ...

  6. jquery ui 笔记

    准备: 1.下载jquery ui库:http://jqueryui.com/download/ 2.选择theme 3.建立一个良好的发展环境(mysql.netbeans) 4.创建数据库:jqu ...

  7. 解决新版Emacs的警告:Warning (initialization): Your load-path...

    升级到新版Emacs后出现警告 作为做好用的代码编辑器之一,Emacs绝对在极客世界实用率很高.当然VIM也有很多支持者.但小编是从VIM转到Emacs的,个人觉得Emacs更好用. 小编最近升级了F ...

  8. PHP之运用CI用钩子实现URL权限控制————————【Badboy】

    <span style="background-color: rgb(247, 252, 255); font-family: Verdana, Arial, Helvetica, s ...

  9. Minimum Sum LCM(uva10791+和最小的LCM+推理)

    L - Minimum Sum LCM Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submi ...

  10. 4安德鲁斯.2.2在系统,具有系统权限的应用程序无法读取或写入SD卡

    有两个解决方案: 1.通过改动android系统的源代码,开放SD卡的读写权限,具体的改动方法和说明.能够參考网上资料http://www.ifeegoo.com/android-debug-stat ...