摘要:欧几里得/扩展欧几里得/模线性方程组(中国剩余定理以及mod不互质的情况)欧几里得/扩展欧几里得/模线性方程组(中国剩余定理 以及mod不互质的情况)/***********欧几里得算法**************/辗转相除法求最大公约数。GCD(a,b)=GCD(b,a mod b)稍微证明一下:(参考:算法导论)证明的思路是大致是这样的:证明 GCD(a,b) | GCD(b,a mod b) 并且 GCD(b,a mod b) | GCD(a,b)先证GCD(a,b) | GCD(b,a mod b):设 d=GCD(a,b),则d|a 并且 d|b那么 a=r+kb (k为整数)也就是
阅读全文
摘要:In most professional sporting events, cheerleaders play a major role in entertaining the spectators. Their roles are substantial during breaks and prior to start of play. The world cup soccer is no exception. Usually the cheerleaders form a group and perform at the centre of the field. In addition t
阅读全文
摘要:Triangle CountingInput:Standard InputOutput:Standard OutputYou are givennrods of length 1, 2…, n. You have to pick any 3 of them & build a triangle. How many distinct triangles can you make? Note that, two triangles will be considered different if they have at least 1 pair of arms with different
阅读全文
摘要:RemainderTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2122Accepted Submission(s): 449 Problem DescriptionCoco is a clever boy, who is good at mathematics. However, he is puzzled by a difficult mathematics problem. The problem is: Given three in
阅读全文
摘要:Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。 我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样
阅读全文
摘要:Time Limit: 1500 ms Memory Limit: 10000 kB Total Submit : 234(77 users)Accepted Submit : 102(72 users)Page View : 3852Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0,
阅读全文
摘要:Time Limit: 5000 ms Memory Limit: 10000 kB Total Submit : 432 (78 users) Accepted Submit : 108 (57 users) Page View : 3479 Font Style: Aa Aa Aa Your task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation? In
阅读全文
摘要:AC代码:#includeusing namespace std;int a[3][3];int d[3][3];int t[3][3];int temp[3][3];void binary(int n){ int i,j,k; while(n) { if(n%2) { for(i=1;i>n,n+1) { if(!n) { cout<<0<<endl; continue; } memset(a,0,sizeof(a));...
阅读全文