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. ubuntu 下修改host文件

    原文地址:http://www.cnblogs.com/kingcat/archive/2012/02/23/2364509.html 有些时候,我们需要让某些域名指向本地,来实现调试,下面介绍下ub ...

  2. [基础] Python问题

    1.中文字符被自动转成ASCII码,然后无论如何编解码都没法被某些函数识别,已然放弃,以后坚决不再使用中文路径 2.缺少什么工具就pip install xxx一下,很好用,就是有个下列Warning ...

  3. 《A First Course in Mathematical Modeling》-chaper1-差分方程建模

    从今天开始笔者将通过这个专栏可是对“数学建模”的学习.其实对于“数学建模”自身的内涵或者意义并不需要太多的阐释,下图简洁明了的阐释了数学建模的意义. 其实数学建模本身可以看成换一种角度去解读数学,将我 ...

  4. mybatis 关联对象mapper.xml的写法

    https://github.com/zfrHJ/mybaties/blob/master/mybaties/src/com/itheima/mybatits/mapper/OrdersMapperC ...

  5. 说说CSS学习中的瓶颈

    虽已数年,但未就学习专门写过文章,这回破处了.苍蝇不叮没有缝隙的鸡蛋,领导不做没有跟拍的表演,同样,想到写CSS学习的文章也是有原因的(虽然我的不少行为没有原因). 情景再现(尊重隐私,下面故事中人名 ...

  6. Y2错题解析

    数据流程图描述信息的来龙去脉和实际流程,反映信息在系统中流动.处理和存储的情况.程序结构图用来描述程序结构,一般由构成系统的要素和表达要素间关系的连线或箭头构成.因果图是一种发现问题"根本原 ...

  7. 小菜学习Lucene.Net(更新3.0.3版本使用)

    花了两天的时间研究了下Lucene.Net 发现确实挺好玩.... 最新版本是3.0.3 (最后更新时间2012-10) 可惜3.0.3版本的Lucene.net无法和盘古分词 (最新版为2.3.1. ...

  8. poj--1579--(DFS+记忆化搜索之经典)

    记忆化搜索   记忆化搜索:算法上依然是搜索的流程,但是搜索到的一些解用 动态规划的那种思想和模式作一些保存. 一般说来,动态规划总要遍历所有的状态,而搜索可以排除一些无效状态. 更重要的是搜索还可以 ...

  9. Delphi系统托盘组件 TTrayIcon 简介

    TTrayIcon 的主要属性: TrayIcon.Icon指定托盘图标, 有几种用法:1.设计时选择;2.把一个 TIcon 对象给它;3.使用当前程序图标: TrayIcon1.Icon := A ...

  10. [CSS3] Using CSS Combinators to Identify Siblings and Descendants in CSS

    CSS combinators allows us to reference the DOM relationship between two or more elements in CSS. < ...