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 ...
随机推荐
- MySQL pt-table-checksum及pt-table-sync校验及修复主从一致性
[pt-table-checksum]pt-table-checksum是percona-toolkit系列工具中的一个, 可以用来检测主. 从数据库中数据的一致性.其原理是在主库上运行, 对同步的表 ...
- jQuery实现select三级联动
参考:jQuery权威指南jQuery初步jQuery选择器jQuery操作domjQuery操作dom事件jQuery插件jQuery操作AjaxjQuery动画与特效jQuery实现导航栏jQue ...
- SpringInAction--Bean的作用域
Spring定义了多种作用域,我们在使用的时候可以根据使用的需求来选择对应的作用域,这些作用域,包括(第二个括号中为更安全的注解方法,具体更多参数可查看接口代码) 单例(Singleton)(Conf ...
- 终于也忍不住来写oi经历了
感觉好绝望. 突然间觉得这么长时间的oi学了就像没学一样,这么多的题做了就像没做一样. 努力付出,却不知希望在何处,也不知道该怎么办. 我好丧啊. 但是又没有办法 既然当初选择oi这条路 就只能继续走 ...
- React中利用axios来实现数据请求
axios是基于Promise来封装的,通常我们会用axios在数据请求这块作如下配置: 一.拦截器 有注释,不难理解,通常请求头参数不是写死的,应该是去浏览器中读的,例如,login之后返回toke ...
- RxJava 1.x 笔记:组合型操作符
最近去检查眼睛,发现度数又涨了,唉,各位猿多注意保护自己的眼睛吧! 前面学了 RxJava 的三种关键操作符: 创建型操作符 过滤型操作符 变换型操作符 读完本文你将了解第四种(组合型操作符): 组合 ...
- SSH项目搭建(二)
本章讲解SSH项目需要到哪些jar包,及各个jar包的作用 一.struts2 1.下载好struts2,struts2文件夹>>>>apps>>>>a ...
- Swift GCD
var queue: dispatch_queue_t = dispatch_get_main_queue()// 主线程 queue = dispatch_get_global_queue(DISP ...
- python中类变量,成员变量
参考文献:http://www.jb51.net/article/54286.htm 转载.引用请附上参考文献的链接. (1)位置的区别 先看看下面这段代码: class TestClass(obje ...
- [javascript]复制到剪切板
<!-- 一个简单的小栗子 --> <button class="copy-link" data-fulllink="要被复制的内容在这里-" ...