HDU1222Wolf and Rabbit(GCD思维)
Wolf and Rabbit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9060 Accepted Submission(s): 4612

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 starts with a positive integer P which 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).
1 2
2 2
YES
/*************************************************************************
> File Name: HDU1222.cpp
> Author: LyuCheng
> Created Time: 2017年10月18日 星期三 21时11分08秒
************************************************************************/
/*
* 题意:大灰狼追小白兔。小白兔可以躲起来的洞绕成一个圈,大灰狼从0这个点出发,
* 每次走m个,问这些洞有木有可以不被狼找到的。
* 思路:如果gcd(n,m)不等于1的话,那么最小公倍数不为n*m,那么用x(x<n)次,大灰
* 狼就会跑到出发位置,肯定不会遍历n个点.
* */
#include <bits/stdc++.h> using namespace std; int t;
int a,b; int main(){
scanf("%d",&t);
while(t--){
scanf("%d%d",&a,&b);
if(__gcd(a,b)==){
puts("NO");
}else{
puts("YES");
}
}
return ;
}
HDU1222Wolf and Rabbit(GCD思维)的更多相关文章
- hdu1222Wolf and Rabbit (公约数的巧题)
一个很坑的问题,想到点子上很好解决,想不到的话头破也不一定能做出来. There is a hill with n holes around. The holes are signed from 0 ...
- CF1025B Weakened Common Divisor【数论/GCD/思维】
#include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include ...
- 【CodeForces 803 C】Maximal GCD(GCD+思维)
You are given positive integer number n. You should create such strictly increasingsequence of k pos ...
- Codeforces Round #651 (Div. 2) A. Maximum GCD (思维)
题意:在\(1\)~\(n\)中找两个不相等的数使得他们的\(gcd\)最大. 题解:水题,如果\(n\)是偶数,那么一定取\(n\)和\(n/2\),\(n\)是奇数的话,取\(n-1\)和\((n ...
- 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= ...
- 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 ...
- Maximal GCD CodeForces - 803C (数论+思维优化)
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 ...
随机推荐
- OC Block网上转载
1.block是一个特殊的OC对象, 它建立在栈上, 而不是堆上, 这么做一个是为性能考虑,还有就是方便访问局部变量. 2.默认情况下block使用到的局部变量都会被复制,而不是保留.所以它无法改变局 ...
- [js高手之路] html5 canvas系列教程 - 认识canvas以及基本使用方法
canvas是html5中引入的一个新元素,俗称画布,既然是画布,当然是用来画图的.canvas技术指的是利用javascript操作canvas元素绘制图形的技术,要使用canvas,一定要浏览器支 ...
- TCP/IP笔记
TCP/IP 连接 三次握手 TCP/IP 四次分手 @TODO TIME_WAIT 状态 有三种状态可以进入此状态 1.由FIN-WAIT-2,双方不同时发起FIN,主动关闭的一方在完成自身发起的关 ...
- 浅析前端开发中的 MVC/MVP/MVVM 模式
MVC,MVP和MVVM都是常见的软件架构设计模式(Architectural Pattern),它通过分离关注点来改进代码的组织方式.不同于设计模式(Design Pattern),只是为了解决一类 ...
- Fix “Could not flush the DNS Resolver Cache: Function failed during execution” When Flushing DNS
ipconfig /flushdns It is possible that you’re getting an error message “Could not flush the DNS Reso ...
- 悟透JavaScript(二)
初看原型 prototype源自法语,软件界的标准翻译为“原型”,代表事物的初始形态,也含有模型和样板的意义.JavaScript中的prototype概念恰如其分地反映了这个词的内含,我们不能将其理 ...
- ZOJ2975 伪数组压缩+组合数
Kinds of Fuwas Time Limit: 2 Seconds Memory Limit:65536 KB In the year 2008, the 29th Olympic G ...
- linux上redis安装配置及其防漏洞配置及其攻击方法
Linux上redis安装: 需先在服务器上安装yum(虚拟机可使用挂载的方式安装) 安装配置所需要的环境运行指令: yum -y install gcc 进入解压文件执行make 指令进行编译 执 ...
- scala中的Type使用
trait Base { val name: String } case class S( name: String, age: Int ) extends Base case class F( na ...
- 【学习】Zepto与jQuery 差别
前几天遇到一个项目,需要把jquery全部改成Zepto,当时因为自己没有实际经验,所以没有接.今天查了一下两者究竟有什么区别. 首先看到了这么一篇文章:http://www.bootcss.com/ ...