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

Problem Description
There is a hill with n holes around. The holes are 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.

 
Input
The
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).
 
Output
For each input m n, if safe holes exist, you should output "YES", else output "NO" in a single line.
 
Sample Input
2
1 2
2 2
 
Sample Output
NO
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思维)的更多相关文章

  1. hdu1222Wolf and Rabbit (公约数的巧题)

    一个很坑的问题,想到点子上很好解决,想不到的话头破也不一定能做出来. There is a hill with n holes around. The holes are signed from 0 ...

  2. CF1025B Weakened Common Divisor【数论/GCD/思维】

    #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include ...

  3. 【CodeForces 803 C】Maximal GCD(GCD+思维)

    You are given positive integer number n. You should create such strictly increasingsequence of k pos ...

  4. Codeforces Round #651 (Div. 2) A. Maximum GCD (思维)

    题意:在\(1\)~\(n\)中找两个不相等的数使得他们的\(gcd\)最大. 题解:水题,如果\(n\)是偶数,那么一定取\(n\)和\(n/2\),\(n\)是奇数的话,取\(n-1\)和\((n ...

  5. Wolf and Rabbit(gcd)

    Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. HDU 1222 Wolf and Rabbit(gcd)

    HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  7. 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 ...

  8. Maximal GCD CodeForces - 803C (数论+思维优化)

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. 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 ...

随机推荐

  1. Eclipse 版本选择

    查看Eclipse的版本号: 1. 找到eclipse安装目录 2. 进入readme文件夹,打开readme_eclipse.html 3. readme_eclipse.html呈现的第二行即数字 ...

  2. RG_5

    必须发博纪念经过昨天的开车, 作业本终于做完啦!!! 可以认真的刷题了.

  3. 翻译:MariaDB ALTER TABLE语句

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  4. Apache Spark 2.2.0 中文文档 - Submitting Applications | ApacheCN

    Submitting Applications 在 script in Spark的 bin 目录中的spark-submit 脚本用与在集群上启动应用程序.它可以通过一个统一的接口使用所有 Spar ...

  5. HCatalog

    HCatalog HCatalog是Hadoop中的表和存储管理层,能够支持用户用不同的工具(Pig.MapReduce)更容易地表格化读写数据. HCatalog从Apache孵化器毕业,并于201 ...

  6. vue学习心得

    前言 使用vue框架有一段时间了,这里总结一下心得,主要为新人提供学习vue一些经验方法和项目中一些解决思路. 文中谨代表个人观点,如有错误,欢迎指正. 环境搭建 假设你已经通读vue官方文档(文档都 ...

  7. 移动端效果之CellSwiper

    写在前面 接着之前的移动端效果讲解,刚好项目中需要使用到这一效果,去饿了么的组件库看了一下效果,发现效果和微信端的cellSwiper还是有点差别的,由于项目中又是使用的React,之前使用的Reac ...

  8. zoj3953 Intervals 最大不重叠区间加强版 zoj排名第一~

    Intervals Time Limit: 1 Second      Memory Limit:65536 KB      Special Judge Chiaki has n intervals ...

  9. Myeclipse 配置Tomcat 出现 “Value must be an existing directory”错误

    今天上午配了一下本机上的Myeclipse的tomcat,因为我本机上有两个版本的myeclipse,一个是用来公司开发的,一个是自己玩的,本机上装了两个版本jdk和两个版本的tomcat.配置自己玩 ...

  10. MVC中@RenderBody、@RenderSection、@RenderPage、@Html.RenderPartial、Html.RenderAction的作用和区别

    1.@RenderBody()   作用和母版页中的服务器控件类似,当创建基于此布局页面的视图时,视图的内容会和布局页面合并,而新创建视图的内容会通过布局页面的@RenderBody()方法呈现在标签 ...