gcd算法是用来求两个数最大公约数的算法,他是依靠辗转相除(中国好像叫辗转相减)法来求两个数的最大公约数,别的地方也有很多介绍不做过多赘述,主要提供代码供自己参考. gcd(int a,int b) { ?a:gcd(b,a%b); } 对于拓展gcd,是对方程ax+by=c求解: 就是a mod b=c这个方程求解: 具体看代码,不做过多赘述因为别人已经讲的很详细了,在这里copy一下别人的讲解: 我们其实只需要考虑形如 a • x mod n = 1 的方程.因为,如果能解出这样的方程, a…
题目链接: https://cn.vjudge.net/problem/HDU-3613 After an uphill battle, General Li won a great victory. Now the head of state decide to reward him with honor and treasures for his great exploit. One of these treasures is a necklace made up of 26 differe…