119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any integer X and Y if 5X+4Y is divided by 23 than 3X+7Y is divided by 23 too.” The task is from city Olympiad in mathematics in Saratov, Russia for schoolc…
题意: 对于给出的一个整数N,和一对(A0,B0) 找到所有的整数对(A,B)满足 : 对于任意 X,Y 当 A0 * X + B0 * Y 能被 N 整除时 A * X + B * Y 也能被 N 整除 Solution: 如果AX+BY能被N整除,则dAX+dBY也能,因A,B<N,所以(dA mod N)X+(dB mod N)Y也能,把所有情况枚举完排序输出 参考代码: #include <stdio.h> #include…
小故事: A * "1+1+1+1+1+1+1+1 =?" * A : "上面等式的值是多少" B : *计算* "8!" A *在上面等式的左边写上 "1+" * A : "此时等式的值为多少" B : *quickly* "9!" A : "你怎么这么快就知道答案了" A : "只要在8的基础上加1就行了" A : "所以你不用重新计…
140. Integer Sequences time limit per test: 0.25 sec. memory limit per test: 4096 KB A sequence A is called an integer sequence of length N if all its elements A1 A2 .. AN are non-negative integers less than 2 000 000 000. Consider two integer sequen…