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. 基于Redis的Bloomfilter去重(转载)

    转载:http://blog.csdn.net/bone_ace/article/details/53107018 前言 “去重”是日常工作中会经常用到的一项技能,在爬虫领域更是常用,并且规模一般都比 ...

  2. PL/SQL Developer 显示中文乱码问题解决

    PL/SQL Developer 显示中文乱码问题简单版本:首先,通过 select userenv('language') from dual;查询oracle服务器端的编码, 如为: AMERIC ...

  3. 2017.6.26 接口测试工具postman使用总结

    参考来自: http://www.cnblogs.com/sunshine-sky66/p/6369963.html http://www.cnplugins.com/tool/specify-pos ...

  4. [ElasticSearch]Java API 之 词条查询(Term Level Query)

    1. 词条查询(Term Query)  词条查询是ElasticSearch的一个简单查询.它仅匹配在给定字段中含有该词条的文档,而且是确切的.未经分析的词条.term 查询 会查找我们设定的准确值 ...

  5. running android lint has encountered a

    近期写学习android编程的的时候,每次保存.java文件的时候,总会跳出例如以下错误 这个错误不是属于程序错误,把它关掉对于编程没有不论什么影响,但每次见到这个就是不爽,希望大神可以解决一下,谢谢 ...

  6. POJ 1144 Network(无向图连通分量求割点)

    题目地址:id=1144">POJ 1144 求割点.推断一个点是否是割点有两种推断情况: 假设u为割点,当且仅当满足以下的1条 1.假设u为树根,那么u必须有多于1棵子树 2.假设u ...

  7. Mysql性能测试诊断

    mysql> showglobal status; 可以列出mysql服务器运行各种状态值,另外,查询mysql服务器配置信息语句: mysql> showvariables; 一.慢查询 ...

  8. #include <>与#include""区别

    <>先去系统目录中找头文件,如果没有在到当前目录下找.所以像标准的头文件 stdio.h.stdlib.h等用这个方法. 而""首先在当前目录下寻找,如果找不到,再到系 ...

  9. sql NextResult()多个结果集

    转自  http://blog.csdn.net/limlimlim/article/details/8626898 注意:当SQL语句中出现两条Select语句,例如:string sql = &q ...

  10. Java 调用存储过程、函数

     一.Java调用存储Oracle存储过程 测试用表: --创建用户表 create table USERINFO ( username ) not null, password ) not null ...