F - 数论

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 //题目意思是 有 0-N 个洞,0 和 N - 1 相连,狼从 0 洞开始,每 m 步进洞抓兔子,问是否有安全的洞,就是狼一直不会进去的洞存在 //就是看 m ,n 是否互质,互质就没有。
 #include <iostream>
#include <stdio.h>
using namespace std; bool func(__int64 a,__int64 b)
{
__int64 temp;
if (a<b)
{
temp=a;
a=b;
b=temp;
}
__int64 c=a%b;
while (c!=)
{
c=a%b;
a=b;
b=c;
}
if (a==) return ;//huzhi
return ;
} int main()
{
int t;
__int64 m,n;
scanf("%d",&t);
while (t--)
{
scanf("%I64d%I64d",&m,&n);
if (m==||n==)
{
printf("NO\n");
continue;
} if (m==&&n==)
{
printf("YES\n");
continue;
} if (func(n,m))
{
printf("NO\n");
}
else
printf("YES\n");
}
return ;
}
 

F - 数论的更多相关文章

  1. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  2. Mysql_以案例为基准之查询

    查询数据操作

  3. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  4. 数论F - Strange Way to Express Integers(不互素的的中国剩余定理)

    F - Strange Way to Express Integers Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format: ...

  5. HDU 2802 F(N) 数论+打表

    题目大意:f[n]-n^3=f[n-2]-(n-1)^3 (n >=3),f[1]=1,f[2]=7,求f[n]. 题目思路:将n^3移到到等式右边化简的到:f[n]=f[n-2]+3n*(n- ...

  6. CROC 2016 - Elimination Round (Rated Unofficial Edition) F - Cowslip Collections 数论 + 容斥

    F - Cowslip Collections http://codeforces.com/blog/entry/43868 这个题解讲的很好... #include<bits/stdc++.h ...

  7. 数学--数论--HDU 2802 F(N) 公式推导或矩阵快速幂

    Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1 ...

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力

    题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...

  9. 【CCPC-Wannafly Winter Camp Day3 (Div1) F】小清新数论(莫比乌斯反演+杜教筛)

    点此看题面 大致题意: 让你求出\(\sum_{i=1}^n\sum_{j=1}^n\mu(gcd(i,j))\). 莫比乌斯反演 这种题目,一看就是莫比乌斯反演啊!(连莫比乌斯函数都有) 关于莫比乌 ...

随机推荐

  1. #define,#undef宏学习

    1.预处理器 1.1预处理符号: __FILE__ :进行编译的源文件名字 __LINE__ :文件当前行的行号 __DATA__ :文件被编译的日期 __TIME__ :文件被编译的时间 __STD ...

  2. C#字符串操作大全

    ===============================字符串基本操作================================ 一.C#中字符串的建立过程 例如定义变量 strT=&qu ...

  3. python 小技巧(glob,guid,序列化,压缩字符,有序字典,sorted函数,分片)

    1.glob模块 glob模块是最简单的模块之一,内容非常少.用它可以查找符合特定规则的文件路径名.跟使用windows下的文件搜索差不多.查找文件只用到三个匹配符:”*”, “?”, “[]”.”* ...

  4. hive bucket

    转载:https://www.cnblogs.com/end/archive/2013/01/09/2852413.html hive中table可以拆分成partition,table和partit ...

  5. 飘逸的python - __get__ vs __getattr__ vs __getattribute__以及属性的搜索策略

    差别: __getattribute__:是无条件被调用.对不论什么对象的属性訪问时,都会隐式的调用__getattribute__方法,比方调用t.__dict__,事实上运行了t.__getatt ...

  6. Appium Android Bootstrap源代码分析之简单介绍

    在上一个系列中我们分析了UiAutomator的核心源代码,对UiAutomator是怎么执行的原理有了根本的了解.今天我们会開始另外一个在安卓平台上基于UiAutomator的新起之秀--Appiu ...

  7. 补充——a.extend(b) #合并列表——a.update(b) #把b字典的元素加入到a字典里面

    1.list dict tulpe a='dongtian'a[0]='h' #会报错,字符串不能修改print(a) a=[]a.append('abc')a.insert(0,'vcc') b=[ ...

  8. ios7中的edgesForExtendedLayout

    edgesForExtendedLayout是一个类型为UIExtendedEdge的属性,指定边缘要延伸的方向. 因为iOS7鼓励全屏布局,所以它的默认值是UIRectEdgeAll——四周边缘都延 ...

  9. linux 下mtime,ctime,atime分析

    一.atime.ctime与mtime atime是指access time,即文件被读取或者执行的时间,修改文件是不会改变access time的.网上很多资料都声称cat.more等读取文件的命令 ...

  10. MyEclipse配置输出控制台信息至文本文件里

    有时会遇到这种情况.输出的信息过多,console控制台显示不全然.这是就须要将输出的信息输出到文本文件里,既能够查看也能够备份. 1.右击须要执行的项目->Run As->Run Con ...