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. U3D 内置对象

    在U3D里面提供了一个Time对象: void OnGUI(){ Debug.Log("########################"); GUILayout.Label (& ...

  2. 测试Kettle在增量更新的时候是否支持级联——不支持(基于mysql)

    由于LZ很像整理一下如何使用Kettle对一张表进行增量更新的时候, 同时实现对数据库中的其他表也可以实现相关的更新操作. 第一种方法想使用触发器,即在相应的hop之间添加SQL脚本step然后在st ...

  3. >=ios8 应用内跳转到系统设置界面-openURL

    iOS8以后,苹果允许从应用内跳转到系统设置,但是调试结果表明,跳不到具体的设置项,使用前应该判断当前是否能够跳转到系统设置. 代码: NSURL *url = [NSURL URLWithStrin ...

  4. C++中extern关键字使用(转)

    参考文章:http://blog.csdn.net/sruru/article/details/7951019 chapter1.如何混合编译C语言和C++ 实际开发过程中,C++中会调用C与语言编写 ...

  5. 【Ural1057】幂和的数量

    [题目描述] 写一个程序来计算区间[X,Y]内满足如下条件的整数个数:它恰好等于K个互不相等的B的整数幂之和. 举个例子.令X=15,Y=20,K=2,B=2.在这个例子中,区间[15,20]内有3个 ...

  6. 简单高效读写修改整个文本Slurp

    语法: use File::Slurp; #标量环境下一次读取所有文本内容到标量中. my $text = read_file( 'filename' ) ; #  读取文本的所有行到数组中. my ...

  7. 第三篇、调优之路 Apache调优

    1.  简介 在第一篇中整合了apache + tomcat ,利用了apache解析静态文件为tomcat解压.但是在测试机上发现两者性能不足,不能充分利用服务器的性能,该篇中将对apache进行性 ...

  8. ios开发之代理&&协议

    Object-C是不支持多继承的,所以很多时候都是用Protocol(协议)来代替.Protocol(协议)只能定义公用的一套接口,但不能提供具体的实现方法.也就是说,它只告诉你要做什么,但具体怎么做 ...

  9. 神秘链接__proto__是什么鬼

    _proto_实际上是某个实例对象的隐藏属性,而prototype是其构造器函数(或者说‘类’)的原型属性; function Mine() {} var  hi = new Function(), ...

  10. yii2源码学习笔记(三)

    组件(component),是Yii框架的基类,实现了属性.事件.行为三类功能,如果需要事件和行为的功能,需要继承该类. yii\base\Component代码详解 <?php /** * @ ...