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 ...
 
随机推荐
- qml 音乐播放器的进度条
			
进度条采用qml的Slider组件 样式什么的,网上很多.我就不列举了.接下来主要说明,进度条是怎样按秒移动的. Slider { id: control value: 0 stepSize: ...
 - 定位CPU高问题三把斧
			
1.top -H -p PID 查看对应进程的哪个线程占用CPU过高 2.printf "%x\n" tid 将需要的线程ID转换为16进制格式 3.jstack pid &g ...
 - Linux:mii-tool命令详解
			
mii-tool 用于查看.管理介质的网络接口的状态 语法 mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...] 选项 -V 显示版 ...
 - Vim技能修炼教程(16) - 浮点数计算函数
			
浮点数计算函数 这一节的所有函数,只有在vim编译时支持了+float时才有效. 三角函数 sin() : sine正弦函数 cos() : cosine余弦函数 tan() : tangent正切函 ...
 - 《机器学习》第三章——LDA
			
import numpy as np x=np.zeros((2,17)) y=np.zeros((1,17)) def dataload(filename): f=open(filename) ar ...
 - Win10安装Ubuntu16.04 双系统
			
Tips: 双系统Ubuntu可以使用机器的GPU硬件,虚拟机不可以 压缩卷留的空间尽量大一点,不要相信50G够用 选UEFI,并关闭 Secure Boot,不要选 Legacy 选UEFI,就要在 ...
 - 会议室预定demo  mrbs
			
关于会议室的增删改查 查: HTML: login继承django自带的admin用户认证系统 <!DOCTYPE html> <html lang="en"&g ...
 - jquery.i18n.properties.js hacking
			
/****************************************************************************** * jquery.i18n.proper ...
 - js之简易计算器
			
<!DOCTYPE html PUBLIC "-//W3C//Dli XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
 - 【javacript】获得点击的标签
			
document.getElementById('content').onclick = function(e) { e = e || window.event; var target = e.tar ...