HDU Wolf and Rabbit
Description
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
Output
Sample Input
Sample Output
#include<iostream>
using namespace std;
int gcd(int a,int b){
return b==?a:gcd(b,a%b);
}
int main(){
int t,n,m;cin>>t;
while(t--){
cin>>m>>n;
if(m==)cout<<"NO"<<endl;
else {
if(gcd(n,m)==)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
}
return ;
}
HDU 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(欧几里得)
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Wolf and Rabbit
http://acm.hdu.edu.cn/showproblem.php?pid=1222 Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others ...
- Wolf and Rabbit(gcd)
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- gcd(最大公约数)lcm(最小公倍数)E - Wolf and Rabbit
1.gcd 递归实现 int gcd(int i,int j){ if(j==0) return i; else return gcd(j,i%j);} 2.lcm int gcd(int i,int ...
- 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 1222 Wolf and Rabbit( 简单拓欧 )
链接:传送门 题意:狼抓兔子,狼从 0 出发沿逆时针寻找兔子,每走一步的距离为 m ,所有洞窟的编号为 0 - n-1 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里 ...
随机推荐
- python中的字符串和数字连接
1. 将数字强制转换成字符串 i = 1000 str1 = "hello" print str1 + str(i) 2. 格式化成字符串 i = 1000 str1 = &quo ...
- [LeetCode]题解(python):026-Remove Duplicates from Sorted Array
题目来源: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题意分析: 给定一个排好序的数组,去除重复的数,返回新 ...
- ubuntu ~/.bash_history
sudo apt-get update sudo apt-get install python-pip sudo pip install Django==1.7.1 sudo apt-get inst ...
- uvalive 2322 Wooden Sticks(贪心)
题目连接:2322 Wooden Sticks 题目大意:给出要求切的n个小木棍 , 每个小木棍有长度和重量,因为当要切的长度和重量分别大于前面一个的长度和重量的时候可以不用调整大木棍直接切割, 否则 ...
- - 通过 UIBezierPath 做一个中空的扫描器
今天在公司的代码里看到通过 UIBezierPath 绘制 CALayer 然后实现中空的正方形,感觉还挺有意思的,简单记录一下 UIBezierPath 这个东西. 一条线 我们自定义一个 Bezi ...
- android自定义控件 onMeasure() 测量尺寸
上次讲的自定义控件刷新点屏幕的任意地方都会刷新,而且在xml里自定义控件下面放一个textview的话,这个TextView是显示不出来的,不只这个,以前的几个自定义控件都是 为什么呢?今天来讲下on ...
- ADS2008 安装方法详解及文件下载
一.我的安装的过程及方法 正常安装的方法: 1.- Install the program. 2.- Copy "license.lic" into "C:\ADS200 ...
- Remoting简单实践
一句话概括 remoting是微软的一种实现在不同的.net应用程序中进行分布式通信的技术 重要概念 原理大致是首先客户端通过remoting通道来获取服务器对象代理,通过序列化与反序列方式实现数据交 ...
- postgres-xc手册生成方法
步骤 检测编译环境 安装编译工具 编译 以上只在linux环境当中进行,本人所用系统ubuntu15.04 检测编译环境 在posgtgresql目录下运行./configure,并安装需要安 ...
- VS 2013上Python的配置
最近有点不务正业,去看了下Python (主要是学校OJ有这个语言,然后可以轻松解决大数据问题,不要说我太坑~~~) 目前感觉python和matlab有些类似,缺少了变量类型声明,总感觉自己写出来的 ...