基础函数: // 最大公约数,欧几里得定理 int gcd(int a, int b) { return b?gcd(b, a % b): a; } // 拓展欧几里得定理 // 求解ax + by = gcd(a,b) int ext_gcd(int a, int b, int &x, int &y) { int tmp, ret; if(!b) { x = 1; y = 0;
又是我们的OJ 题目链接: http://www.cn210.com/onlinejudge/problemshow.php?pro_id=92 Description tancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only one problem - Petru has locked the spacecraft with a sophisticated cryptosystem based on the ID numbers of the stars
http://www.cn210.com/onlinejudge/problemshow.php?pro_id=98 我们的OJ Description </center> Input The next line contains the numbers of S: x1, x2, ..., xn. It is known that each xi is an integer, 0 ≤ xi ≤ 2*109. The input data set is correct and ends with an end of file. </div> Output Sample Input 2 1 2 3 1 3 9 4 1 2 3 6 Sample Output 1 12 4 首先由于行列式交换