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
 
 
给出两个数,如果它们的公约数大于1就输出YES,否则输出NO
 
#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;
cout<<((gcd(m,n)>)?"YES":"NO")<<endl;
}
return ;
}

集训第六周 数学概念与方法 概率 数论 最大公约数 G题的更多相关文章

  1. 集训第六周 数学概念与方法 概率 F题

    Submit Status Description Sometimes some mathematical results are hard to believe. One of the common ...

  2. 集训第六周 数学概念与方法 概率 N题

    N - 概率 Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status ...

  3. 集训第六周 数学概念与方法 数论 筛素数 H题

    Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识.  问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“ ...

  4. 集训第六周 数学概念与方法 计数 排列 L题

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

  5. 集训第六周 数学概念与方法 J题 数论,质因数分解

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

  6. 集训第六周 数学概念与方法 数论 线性方程 I题

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

  7. 集训第六周 数学概念与方法 UVA 11181 条件概率

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18546 题意:有n个人会去超市,其中只有r个人会买东西,每个人独自买东西的概 ...

  8. 集训第六周 数学概念与方法 UVA 11722 几何概型

    ---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[ ...

  9. 集训第六周 古典概型 期望 D题 Discovering Gold 期望

    Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...

随机推荐

  1. Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger

    myeclipse 新建web项目,报错Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger,查看项目中已经有引入了 ...

  2. [poj2096] Collecting Bugs【概率dp 数学期望】

    传送门:http://poj.org/problem?id=2096 题面很长,大意就是说,有n种bug,s种系统,每一个bug只能属于n中bug中的一种,也只能属于s种系统中的一种.一天能找一个bu ...

  3. dotnetty源码解读一些要点

    DefaultAttributeMap 它绑定在Channel或者ChannelHandlerContext上的一个附件. ChannelHandlerContext都是ChannelHandler和 ...

  4. this关键字的构造方法的使用

    package com.wh.Object3; public class this_Demo { private String name; private double price; private ...

  5. 转】在Ubuntu中安装Cassandra

    原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/ 感谢! Posted: Mar 22, 2014 Tags: cas ...

  6. 配置Oracle监听器

    Oracle的监听和网络服务都可以在Net Manager中配置,如下图.也可以在上面的那个Net Configuration Assistant中配置,只是Net Manager比较方便些. Ora ...

  7. Docker安装jenkins(六)

    这里是在linux环境下安装docker之后,在doucer内安装jenkins --------------------docker 安装 jenkins---------------------- ...

  8. WordPress更改固定链接出现404

    新浪SAE的前端采用的是nginx,nginx是不识别.htaccess的. 最后学习了新浪SAE官方教程——应用配置模块 – AppConfig终于把问题解决! 1.修改你SAE SDK站点目录下的 ...

  9. Javaweb项目构建常见问题

    eclipse中 将java项目转换为web项目 1.找到项目工作空间目录,打开.project文件,并修改文件, 修改如下:      找到:<natures> </natures ...

  10. jQuery之Validation表单验证插件使用

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <met ...