Wolf and Rabbit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9485    Accepted Submission(s):
4857

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   |   We have carefully selected several
similar problems for you:  1207 1299 1219 2175 1995 
 #include <iostream>
#include <cstring>
using namespace std;
int gcd(int a, int b)
{
int t;
if (a < b) { t = a; a = b; b = t; }
return b == ? a : gcd(b, a%b);
}
int main()
{
int t;
int m, n;
cin >> t;
while (t--)
{
cin >> m >> n;
int d = gcd(m, n);
if (d == ) cout << "NO" << endl;
else cout << "YES" << endl;
}
return ;
}

HDU 1222 Wolf and Rabbit(欧几里得)的更多相关文章

  1. HDU 1222 Wolf and Rabbit(gcd)

    HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  2. HDU 1222 Wolf and Rabbit( 简单拓欧 )

    链接:传送门 题意:狼抓兔子,狼从 0 出发沿逆时针寻找兔子,每走一步的距离为 m ,所有洞窟的编号为 0 - n-1 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里 ...

  3. hdu 1222 Wolf and Rabbit

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

  4. HDU 1222 Wolf and Rabbit(数学,找规律)

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  5. HDU 1222 - Wolf and Rabbit & HDU 1108 - [最大公约数&最小公倍数]

    水题,只是想借此记一下gcd函数的模板 #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { ...

  6. hdu 1573 A/B (扩展欧几里得)

    Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)= 1). Input 数据的第一行 ...

  7. 【HDOJ】1222 Wolf and Rabbit

    最大公约数,辗转相除. #include <stdio.h> long long gcd(long long a, long long b) { if (a<b) return gc ...

  8. Wolf and Rabbit

    http://acm.hdu.edu.cn/showproblem.php?pid=1222 Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others ...

  9. 扩展欧几里得 hdu 1576

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 不知道扩展欧几里得的同学可以参考:https://blog.csdn.net/zhjchengf ...

随机推荐

  1. Pavilion M4-1016TX 加装固态硬盘(SSD)+UEFI+GPT安装WIN8.1

    折腾了一天,终于将电脑加上SSD和装上系统,记录下,方便后面忘记使用. 步骤: 1.Pavilion M4-1016TX内置了mSata的接口,大小是全高的.ssd支持大小官方说法是测试过32g的,目 ...

  2. ES6入门之对象扩展

    ES5对象(超类)原有: 属性:construct构造函数 方法: object.hasOwnProperty( propertyName ) //检测是否有一个本地的属性而不是继承的,返回boole ...

  3. 多网卡下,vlc发送IGMP组播报告包

    这两天测试IGMP遇到一个问题,环境描述如下: 我的vlc客户端安装在windows下,该PC有两张网卡,本地连接1接公司网,本地链接2 接路由器.wireshark坚挺本地链接2,以测试路由的IGM ...

  4. 2018.11.12 RF debug

    1 SG setting 2 Date 3  0-1 4 ASK 5 Power supply 6  SG - filter 7 NRF905-  demodulation 8  RX test 9 ...

  5. Slice Header中的field_pic_flag的含义?

    编码模式指帧编码.场编码.帧场自适应编码.当这个句法元素取值为1时属于场编码:0为非场编码. 序列参数集中的句法元素frame_mbs_only_flag和mb_adaptive_frame_fiel ...

  6. HTML中Div、span、label标签的区别

    div与span 大家在初学div+css布局时,有很多困惑,在div与span的使用过程没觉得有一定的”章法”,觉得两个区别不大,在w3c的关于div和span的定义:div作为分割文档结构自然使它 ...

  7. 使用PullToRefreshListView时遇到Item点击事件失效问题 解决方法

    最近在自己的项目中使用到了以下开源项目: https://github.com/nanchen2251/pullToRefreshDemo 相关介绍博客如下: http://www.cnblogs.c ...

  8. C程序fork进程导致PHP执行不退出

    /********************************************************************* * C程序fork进程导致PHP执行不退出 * 说明: * ...

  9. IOS在Document目录下创建文件夹、保存、读取、以及删除文件

    // 在Documents目录下创建一个名为LaunchImage的文件夹 NSString *path = [[NSHomeDirectory() stringByAppendingPathComp ...

  10. BZOJ4975: [Lydsy1708月赛]区间翻转( 博弈&逆序对)

    4975: [Lydsy1708月赛]区间翻转 Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 265  Solved: 140[Submit][Stat ...