hdu 1222 Wolf and Rabbit

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.
#include<stdio.h>
int main()
{
int m,n,i,k,flag,t;
scanf("%d",&k);
for(i=;i<=k;i++)
{
scanf("%d%d",&n,&m);
while(m!=)
{
t=n%m;
n=m;
m=t;
}
if(n==)
printf("NO\n");
else
printf("YES\n");
}
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(欧几里得)
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 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 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里 ...
- 【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 ...
- 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 ...
随机推荐
- 广州项目实施步骤II_练习配置HaProxy的重定向负载均衡
CentOS6.4 配置Haproxy Haproxy下载地址:http://pan.baidu.com/share/link?shareid=1787182295&uk=18290183 ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Codeforces Round #260 (Div. 1) A - Boredom DP
A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A ...
- C#创建windows服务搭配定时器Timer使用实例(用代码做,截图版)
功能说明:C#创建一个windows服务,服务启动时D:\mcWindowsService.txt写入数据,服务运行期间每隔两秒写入当前时间. 原理这些就不说了,三语两语说不清楚,直接贴一个实例 ...
- org.apache.catalina.mbeans.ServerLifecycleListener
Tomcat 启动报错: java.lang.ClassNotFoundException: org.apache.catalina.mbeans.ServerLifecycleListener at ...
- 浅谈模块化的JavaScript
模块化JavaScript之风早已席卷而来, CommonJS . AMD . NodeJS .RequireJS . SeaJS . curljs 等模块化的JavaScript概念及库扑面而来, ...
- 信号之sigaction函数
sigaction函数的功能是检查或修改与指定信号相关联的处理动作(或同时执行这两种操作). #include <signal.h> int sigaction( int signo, c ...
- C++类设计2(Class with pointer members)
二 Class with pointer members(Class String) 1. 测试代码(使用效果) int main() { String s1(), String s2("h ...
- C# 自定义重绘TabControl
using System.Drawing; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Runti ...
- 企业级搜索引擎Solr 第三章 索引数据(Indexing Data)[2]--DIH
转载:http://quweiprotoss.wap.blog.163.com/w2/ DIH需要在solrconfig.xml中注册,如下: <requestHandler name=&quo ...