时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:266 解决:189 题目描述: Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of l
1.欧几里得算法(辗转相除法) 直接上gcd和lcm代码. int gcd(int x,int y){ ?x:gcd(y,x%y); } int lcm(int x,int y){ return x*y/gcd(x,y); } 2.扩欧:exgcd:对于a,b,一定存在整数对(x,y)使ax+by=gcd(a,b)=d ,且a,b互质时,d=1. x,y可递归地求得. 我懒得改返回值类型了 long long exgcd(long long a,long long b,long long &x,
只看懂了CRT,EXCRT待补.... 心得:记不得这是第几次翻CRT了,每次都有迷迷糊糊的.. 中国剩余定理用来求解类似这样的方程组: 求解的过程中用到了同余方程. x=a1( mod x1) x=a2( mod x2) x=a3( mod x3) 假设: n1=a1( mod x1) n2=a2( mod x2) n3=a3( mod x3)已知n1满足除以3余2,能不能使得n1+n2的和仍然满足%x1=a1? 所以n2应该是x2的倍数,其余同理. 所以当答案为n1+n2+n3时,n1应该是
题目链接:http://lightoj.com/volume_showproblem.php?problem=1319 In 'MonkeyLand', there is a traditional game called "Bamboo Climbing". The rules of the game are as follows: ) There are N monkeys who play this game and there are N bamboos of equal he