随笔分类 - Number Theory
摘要:More is betterTime Limit: 5000/1000 MS (Java/Others)Memory Limit: 327680/102400 K (Java/Others)Total Submission(s): 11102Accepted Submission(s): 4133Problem DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be
阅读全文
摘要:A/BTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1368Accepted Submission(s): 1044Problem Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。每组数据有两个数n(0 2 # include 3 using namespace std; 4 void.
阅读全文
摘要:了解扩展欧几里德算法,可以问度娘, 大意:可以运用其解出gcd(a,b)=ax1+by1中的x1、y1的值上代码: 1 int extend(int a,int b,int &x,int &y) 2 { 3 if(b == 0) 4 { 5 x = 1; 6 y = 0; 7 return a; 8 } 9 int gcd = extend(b,a%b,x,y);10 int temp = x;11 x = y;12 y = temp - (a/b)*y;13 return gcd;...
阅读全文