HDU 1222 Wolf and Rabbit(欧几里得)
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
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.
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 "YES", else output "NO" in a single line.
1 2
2 2
YES
#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(欧几里得)的更多相关文章
- HDU 1222 Wolf and Rabbit(gcd)
HDU 1222 Wolf and Rabbit (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- HDU 1222 Wolf and Rabbit( 简单拓欧 )
链接:传送门 题意:狼抓兔子,狼从 0 出发沿逆时针寻找兔子,每走一步的距离为 m ,所有洞窟的编号为 0 - n-1 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里 ...
- 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 ...
- HDU 1222 Wolf and Rabbit(数学,找规律)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- 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() { ...
- hdu 1573 A/B (扩展欧几里得)
Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)= 1). Input 数据的第一行 ...
- 【HDOJ】1222 Wolf and Rabbit
最大公约数,辗转相除. #include <stdio.h> long long gcd(long long a, long long b) { if (a<b) return gc ...
- Wolf and Rabbit
http://acm.hdu.edu.cn/showproblem.php?pid=1222 Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others ...
- 扩展欧几里得 hdu 1576
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 不知道扩展欧几里得的同学可以参考:https://blog.csdn.net/zhjchengf ...
随机推荐
- new/delete工作机制
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- 谷歌模拟手机和真机上显示的各个机型的 dpi--和高度
**以下数据尚未经过严密测试.待日后工作中再试** var dpi = window.devicePixelRatio;//获取屏幕分辨率 alert("dpi为:"+dpi); ...
- C++设计模式之-建造者模式
建造者模式的定义将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示(DP).<大话设计模式>举了一个很好的例子——建造小人,一共需建造6个部分,头部.身体.左右手.左 ...
- Linux 内核驱动自动创建设备节点并挂载设备
*注:本文来自http://blog.csdn.net/lwj103862095/article/details/17470573 一.首先需要在最开始定义两个数据结构: static struct ...
- (转)MapReduce Design Patterns(chapter 3 (part 1))(五)
Chapter 3. Filtering Patterns 本章的模式有一个共同点:不会改变原来的记录.这种模式是找到一个数据的子集,或者更小,例如取前十条,或者很大,例如结果去重.这种过滤器模式跟前 ...
- CSDN博客积分规则
1.博客积分规则 博客积分是CSDN对用户努力的认可和奖励,也是衡量博客水平的重要标准.博客等级也将由博客积分唯一决定.积分规则具体如下: 每发布一篇原创或者翻译文章:可获得10分: 每发布一篇转载文 ...
- Linux下打开windows中文文本乱码问题
1. 查看文件的编码方式:file命令 $ file test_file.txt test_file.txt: ISO- text, with very long lines $ file train ...
- 重写alert 方法(我胡汉三又回来了)
window.alert = function (txt) { var shield = document.createElement("DIV"); shield.id = &q ...
- 自己手写一个SpringMVC框架
前端框架很多,但没有一个框架称霸,后端框架现在Spring已经完成大一统.所以学习Spring是Java程序员的必修课. Spring框架对于Java后端程序员来说再熟悉不过了,以前只知道它用的反射实 ...
- EP-N8530S USB WIFI 驱动移植
/*********************************************************************** * EP-N8530S USB WIFI 驱动移植 * ...