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. [Locked] Flatten 2D Vector

    Problem Description: Implement an iterator to flatten a 2d vector. For example,Given 2d vector = [ [ ...

  2. [Hibernate] List 映射例子

    List 是 java 集合的一个工具,存储线性的数据,允许重复数据.开发者可以准确控制在 list 那个位置插入数据.本例子演示 Java 的 List 集合和 MySQL 数据库的映射应用. 使用 ...

  3. [转]C服务端与java客户端的socket通信注意事项

    http://blog.csdn.net/gaoxin1076/article/details/7671752 Socket网络通讯开发总结之:Java 与 C进行Socket通讯 注意以下问题: 1 ...

  4. hdoj 2085 核反应堆【水】

    核反应堆 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  5. hdu 1106 排序

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  6. 422. Valid Word Square

    似乎可以沿着对角线往右往下检查,也可以正常按题设检查. 我用的后者.. public class Solution { public boolean validWordSquare(List<S ...

  7. Spring二 Bean详解

    Bean详解 Spring框架的本质其实是:通过XML配置来驱动Java代码,这样就可以把原本由java代码管理的耦合关系,提取到XML配置文件中管理.这样就实现了系统中各组件的解耦,有利于后期的升级 ...

  8. STUCTS LABLE ‘S BENEFIT

    {LJ?Dragon}[注]Struts标签的三个好处 RELATED LINKS 0.UTF-8 有无BOM的区别 UTF-8 BOM 06. 几款网页数据抓取软件 SOFTWARE_INTRODU ...

  9. [转] C++指针加整数、两个指针相减的问题

    http://blog.csdn.net/onlyou930/article/details/6725051 说来惭愧,写C++有一段时间了.这个问题从来没有认真考虑过,此次标记于此: 考虑如下问题: ...

  10. iOS教你轻松打造瀑布流Layout

    前言 : 在写这篇文章之前, 先祝贺自己, 属于我的GitHub终于来了. 这也是我的GitHub的第一份代码, 以下文章的代码均可以在Demo clone或下载. 欢迎大家给予意见. 觉得写得不错的 ...