G - 数论,最大公约数

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

 

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
 

题解:只要m,n的最大公约数为1,就没有输出NO,否则输出YES

#include<iostream>
using namespace std;
int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
int t,m,n;
cin>>t;
while(t--)
{
cin>>m>>n;
if(gcd(m,n)==)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
}

第六周 G题的更多相关文章

  1. 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)

    第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...

  2. hdu 4548 第六周H题(美素数)

    第六周H题 - 数论,晒素数 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   De ...

  3. Codeforces 559A 第六周 O题

    Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...

  4. 福建工程学院寒假作业第一周G题

    涨姿势题1 TimeLimit:1000MS  MemoryLimit:128000KB 64-bit integer IO format:%lld   涨姿势题就是所谓的优化题,在组队赛中,队伍发现 ...

  5. 第六周 E题 期望.....

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  6. 第六周 N题

    Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...

  7. HDU 1465 第六周L题

    Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!  做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样.  ...

  8. HDU 1405 第六周 J题

    Description Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all ...

  9. HDU 2669 第六周 I题

    Description The Sky is Sprite.  The Birds is Fly in the Sky.  The Wind is Wonderful.  Blew Throw the ...

随机推荐

  1. FreeMarker-TemplateLoader

    Java中不乏优秀的模板引擎,Velocity,mvel,FreeMarker等.在构建框架的时候,通常可以拿来即用,但我们需要控制它.最近需要一个数据准备的框架,便选择了FreeMarker,Fre ...

  2. VSTS负载测试——如何:使用 SQL 创建结果存储区

    原文地址:http://www.cnblogs.com/chenxizhang/archive/2009/06/01/1493939.html 原文参见:http://msdn.microsoft.c ...

  3. logback 配置详解(一)(转)

    转自:http://blog.csdn.net/haidage/article/details/6794509/ 一:根节点<configuration>包含的属性: scan: 当此属性 ...

  4. keil中for循环变量递减,无法跳出循环的问题

    定义j时应注意其变量类型char,此循环当j=0时,再执行一次则keil中j=0XFF,而不是-1,所以无法跳出循环.但在vc6.0中是可以跳出循环的. 解决办法如下:不能让j的值为负数 uchar ...

  5. C#的dictionary使用总结

    Dictionary<string, string>是一个泛型,本身有集合的功能有时候可以把它看成数组. 他的结构是这样的:Dictionary<[key], [value]> ...

  6. Ken Norton和软件工程师打交道的10个秘诀

    How to work with software engineers - by Ken Norton Deflect praise Absorb blame Sweat the details In ...

  7. backgroundworker组件的使用

    本文转载:http://www.cnblogs.com/inforasc/archive/2009/10/12/1582110.html BackgroundWorker 组件用来执行诸如数据库事务. ...

  8. 使用ef code first模式,在部署后服务器端把数据库同步到最新版本的方法

    共有两种方法: 1.使用migrate.exe 具体使用方法请参考 msdn migrate使用方法,这里只做介绍 复制migrate.exe 在使用 NuGet 安装实体框架时,migrate.ex ...

  9. jquery.cookie用法详细解析

    本篇文章主要是对jquery.cookie的用法进行了详细的分析介绍,需要的朋友可以过来参考下,希望对大家有所帮助 Cookie是由服务器端生成,发送给User-Agent(一般是浏览器),浏览器会将 ...

  10. Phonegap 安卓的自动升级与更新。当版本为4.0的时候

    清单文件中: <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/> ...