G - 数论,最大公约数

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

Submit Status

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
程序代码:
 #include <cstdio>
using namespace std;
long long hcf(long long a,long long b)
{
if(b==)
return a;
else
return hcf(b,a%b);
}
int main()
{
int t;
long long m,n;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&m,&n);
if(hcf(m,n)==)
printf("NO\n");
else
printf("YES\n");
}
return ;
}
 
 
 

数学概念——G 最大公约数的更多相关文章

  1. 21副GIF动图让你了解各种数学概念

    baidu 21副GIF动图让你了解各种数学概念

  2. 转:21副GIF动图让你了解各种数学概念

    21副GIF动图让你了解各种数学概念

  3. Math concepts / 数学概念

    链接网址:Math concepts / 数学概念 – https://www.codelast.com/math-concepts-%e6%95%b0%e5%ad%a6%e6%a6%82%e5%bf ...

  4. 集训第六周 数学概念与方法 概率 数论 最大公约数 G题

    Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...

  5. 数学概念 —— 奇异性(Singularity,Vertical tangent)

    0. 基本定义 Singularity (mathematics) 数学上的奇异性一般是指,函数在该点未定义(not defined,比如取值为无穷),或者不可微(fails to be well-b ...

  6. slot游戏中的数学概念

    最近研究slot 算法,看了大量的英文资料,因为母语中文,一直使用中文的英文小白来说,好心塞,悔不当初没学好英文. 下文是从众多的英文中摘录的唯一能够看明白的概念.先给自己留着,到时候深入研究可以看 ...

  7. 数学概念 z

    数学是很难的科学,但因为它是科学家用数学来解释宇宙的语言,我们无可避免的要学习它.看看下面的这些 GIF 动图,它们提供了视觉的方式来帮助你理解各种数学技巧. 1.椭圆的画法 2.杨辉三角问题(Pas ...

  8. 数学概念——I - 数论,线性方程

    I - 数论,线性方程 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  9. 数学概念——F 概率(经典问题)birthday paradox

    F - 概率(经典问题) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

随机推荐

  1. WPF TextElement内容模型简介(转)

    本内容模型概述描述了 TextElement 支持的内容. Paragraph 类是 TextElement 的类型. 内容模型描述哪些对象/元素可以包含在其他对象/元素中. 本概述汇总了派生自 Te ...

  2. PAT_2-08. 用扑克牌计算24点

    一副扑克牌的每张牌表示一个数(J.Q.K分别表示11.12.13,两个司令都表示6).任取4张牌,即得到4个1~13的数,请添加运算符 (规定为加+ 减- 乘* 除/ 四种)使之成为一个运算式.每个数 ...

  3. CI 笔记(1)

    1. 下载CI,官方网站,目前3.x版本已经更新,2.2.6版本为2.x版本的最后的一个版本.为了和视频教材一致,使用CI 2.x版本 2. 目录结构,从application里面的,controll ...

  4. 进程识别号(PID)的理解

    PID(Process Identification)操作系统里指进程识别号,也就是进程标识符.操作系统里每打开一个程序都会创建一个进程ID,即PID. PID(进程控制符)英文全称为Process ...

  5. Debug your C# project more efficiently

    I am a very beginner working with C# and Visual Studio 2013. When I debug my project, I always reope ...

  6. javascript基础学习(八)

    javascript之日期对象 学习要点: 日期对象 将日期对象转换为字符串 将日期对象中的日期和时间转换为字符串 日期对象中的日期 日期对象中的时间 设置日期对象中的日期 设置日期对象中的时间 与毫 ...

  7. MYSQL命令行连接数据库

    连接数据库 mysql -uroot -proot -P3306 -Dmydemo # 参数详解 -uuser 用户user -ppwd 密码 -P3306 端口 -Dmysql 数据库 #显示所有数 ...

  8. C++前置++与后置++的区别与重载

    ++属于单目运算符,前置与后置的实现代码不一样,下面以整数自增为例: // 前置++,返回自增后的值,且返回的是一个左值 int& operator++(){ *this += 1; retu ...

  9. 异步IO简介

    最近想学习一下libevent,就先翻译一下libevent的官方文档吧. 英文原文链接:http://www.wangafu.net/~nickm/libevent-book/01_intro.ht ...

  10. 【cogs858】磁性链

    [题目描述] 有N块编号为1~N的特殊磁石相互吸附组成一条磁性链,只有它们紧挨着时才会传递吸力,他们之间的吸力很大,如果我们要从N块相连的磁石中取出一块,那么需要消耗N-1个单位的能量,空缺处不再有吸 ...