Wolf and Rabbit
http://acm.hdu.edu.cn/showproblem.php?pid=1222
Wolf and Rabbit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6052 Accepted Submission(s): 3032

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.
1 2
2 2
YES
题解:就是求n和m 是否互质,求gcd(n,m)是否等于1即可
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int gcd (int a , int b)
{
return b==? a :gcd(b,a%b);
}
int main()
{
int n , m ;
int t ;
cin>>t;
while(t--)
{
scanf("%d%d",&n,&m);
if(gcd(n,m)==)
cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return ;
}
Wolf and Rabbit的更多相关文章
- Wolf and Rabbit(gcd)
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 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 ...
- 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 ...
- 转化为用欧几里得算法判断互质的问题D - Wolf and Rabbit
Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...
- HDU Wolf and Rabbit
Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...
- GCD(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( ...
随机推荐
- C#中MessageBox用法大全(附效果图)
1.最简单的,只显示提示信息 2. 可以给消息框加上标题. 3. "确定"和"取消" 4. 给MessageBox加上一个Icon,.net提供常见的Icon共 ...
- bzoj 3991: [SDOI2015]寻宝游戏
Description 小B最近正在玩一个寻宝游戏,这个游戏的地图中有N个村庄和N-1条道路,并且任何两个村庄之间有且仅有一条路径可达.游戏开始时,玩家可以任意选择一个村庄,瞬间转移到这个村庄,然后可 ...
- nova创建虚拟机源码分析系列之一 restful api
开始学习openstack源码,源码文件多,分支不少.按照学习的方法走通一条线是最好的,而网上推荐的最多的就是nova创建虚机的过程.从这一条线入手,能够贯穿openstack核心服务.写博文仅做学习 ...
- ADG监控
cx_Oracle环境配置 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 ...
- Cleaner, more elegant, and wrong(msdn blog)
Cleaner, more elegant, and wrong Just because you can't see the error path doesn't mean it doesn't e ...
- python3.5 + PyQt5 +Eric6 实现的一个计算器
目前可以实现简单的计算.计算前请重置,设计的时候默认数字是0,学了半天就做出来个这么个结果,bug不少. python3.5 + PyQt5 +Eric6 在windows7 32位系统可以完美运行 ...
- prototype为对象添加属性和方法
可以通过prototype来为已经定义好的的"类"添加属性和方法.这里来了解一下prototype的基础知识.prototype是"构造函数"的属性,不是实例的 ...
- Python Pandas 库的使用例子
主要在jupyter notebook里面熟悉这个库的使用,它的安装方法与实现,可自行搜索. Pandas是一个优秀的数据分析工具,官网:http://pandas.pydata.org/ 相关的库使 ...
- [编织消息框架][网络IO模型]NIO(select and poll)
上面测试论证系统内核在read data时会阻塞,如果我们在把第一个阶段解决掉那么性能就会提高 NIO 编程 JDK 1.4中的java.nio.*包中引入新的Java I/O库,其目的是提高速度.实 ...
- Java的成员变量初始化
对于方法里面的成员变量,Java要求程序员强制提供一个初始化的值.比如下面这个方法就会出错: public class Breakyizhan{ public void Z(){ int z; z++ ...