HDU 1222 Wolf and Rabbit(欧几里得)】的更多相关文章

Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9485    Accepted Submission(s): 4857 Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1.…
HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/G 题目: 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…
链接:传送门 题意:狼抓兔子,狼从 0 出发沿逆时针寻找兔子,每走一步的距离为 m ,所有洞窟的编号为 0 - n-1 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里德,设 st 为兔子洞窟编号( 0 <= st < n ),很简单就可以得到一个方程 0 + m * x = n * y + st,化简一下得到 m * x - n * y = st,如果这个方程有解,那么兔子一定能被狼抓到.方程有解的条件是 st % d == 0 ,当 d == 1 时,显然是…
Problem 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…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9848    Accepted Submission(s): 5011 Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hi…
水题,只是想借此记一下gcd函数的模板 #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { int n,m,t; scanf("%d",&t); while(t--){ scanf("%d%d",&m,&n); ) printf("NO\n"); else printf("YES\n"); }…
Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)= 1). Input 数据的第一行是一个T,表示有T组数据. 每组数据有两个数n(0 <= n < 9973)和B(1<= B <= 10^9). Output 对应每组数据输出(A/B)%9973. Sample Input 2 1000 53 87 123456789 Sample Output 7922 6060…
最大公约数,辗转相除. #include <stdio.h> long long gcd(long long a, long long b) { if (a<b) return gcd(b, a); if (!b) return a; else return gcd(b, a%b); } int main() { int case_n; long long m, n; scanf("%d", &case_n); while (case_n--) { scanf…
http://acm.hdu.edu.cn/showproblem.php?pid=1222 Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6052    Accepted Submission(s): 3032 Problem Description There is a hill with n hol…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 不知道扩展欧几里得的同学可以参考:https://blog.csdn.net/zhjchengfeng5/article/details/7786595 我的推理: 这图片是真的大啊... #include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<…