F - 数论
F - 数论
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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
Output
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 - 数论的更多相关文章
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- Mysql_以案例为基准之查询
查询数据操作
- 数学--数论--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 ...
- 数论F - Strange Way to Express Integers(不互素的的中国剩余定理)
F - Strange Way to Express Integers Time Limit:1000MS Memory Limit:131072KB 64bit IO Format: ...
- 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- ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) F - Cowslip Collections 数论 + 容斥
F - Cowslip Collections http://codeforces.com/blog/entry/43868 这个题解讲的很好... #include<bits/stdc++.h ...
- 数学--数论--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 ...
- 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 ...
- 【CCPC-Wannafly Winter Camp Day3 (Div1) F】小清新数论(莫比乌斯反演+杜教筛)
点此看题面 大致题意: 让你求出\(\sum_{i=1}^n\sum_{j=1}^n\mu(gcd(i,j))\). 莫比乌斯反演 这种题目,一看就是莫比乌斯反演啊!(连莫比乌斯函数都有) 关于莫比乌 ...
随机推荐
- 利用Python,四步掌握机器学习
为了理解和应用机器学习技术,你需要学习 Python 或者 R.这两者都是与 C.Java.PHP 相类似的编程语言.但是,因为 Python 与 R 都比较年轻,而且更加“远离”CPU,所以它们显得 ...
- 发布android apk,Error running app: No target device found.
https://developer.android.com/studio/run/device.html\ 一台android设备不识别,android文档还挺全 需要安装usb驱动链接里有
- 用word2vec对语料进行训练
在Linux上安装好word2vec, 进入trunk文件夹,把分词后的语料文件放在trunk文件夹内,执行:./word2vec -train tt.txt -output vectors.bin ...
- Android学习(十四) Service组件
一.定义 运行在后台,没有页面,不可见.优先级高于Activity,当系统内存不足时,会先释放一些Activity.注意,Service同样是运行在主线程中,不能做一些耗时操作.如果一定要做一些耗时的 ...
- Oracle基础 PL-SQL编程基础(3) 循环结构
循环结构: 1. LOOP循环结构 语法: LOOP 要执行的语句; EXIT WHEN <条件> --条件满足则退出循环 END LOOP; 示例:循环输出1-10的整数 DECLA ...
- linux驱动current,引用当前进程,及task_struct(转)
尽管内核模块不象应用程序一样顺序执行, 内核做的大部分动作是代表一个特定进程的. 内核代码可以引用当前进程, 通过存取全局项 current, 它在 <asm/current.h> 中定义 ...
- 【Shell】Read命令
read命令从键盘读取变量的值,通常用在shell脚本与用户进行交互的场合.该命令可以一次性读取多个变量的值,变量的输入和输出需要使用空格隔开.在read命令后面,如果没有指定变量名,读取的数据将被自 ...
- 【BZOJ4008】【HNOI2015】亚瑟王 概率DP
链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...
- 利用CFAbsoluteTimeGetCurrent()计算时间差
开发中,遇到计算时间差的问题,利用CFAbsoluteTimeGetCurrent()可以很方便的进行计算 实例: 场景:类似购物车中修改商品数量的功能,如下图所示,要求,修改完的数量,要同步到服务器 ...
- CLR 完全介绍
From: http://msdn.microsoft.com/zh-cn/magazine/cc164193.aspx http://msdn.microsoft.com/en-us/magazin ...