2014年8月21日
摘要: 题意:对于方程组x=a(mod b)求x。做法:中国剩余定理和拓展欧几里得。代码:#include #include #include using namespace std;typedef long long int64;int64 gcd(int64 a, int64 b){return (b ... 阅读全文
posted @ 2014-08-21 18:48 一锅土豆 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题意:见题目。做法:扩展欧几里得做法。代码:#include #include using namespace std;typedef long long int64;int64 gcd_ex(int64 a, int64 b,int64& x,int64&y){ if (b==0) {x=1... 阅读全文
posted @ 2014-08-21 12:01 一锅土豆 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 辗转相除法:求(a,b)的做法,原理:(a,b)=(b,a%b),当右项为0时,左项即为最大公约数。代码:typedef long long int64;int64 gcd(int64 a, int64 b){return (b == 0)? a: gcd(b, a % b);}扩展欧几里得算法:对... 阅读全文
posted @ 2014-08-21 11:13 一锅土豆 阅读(89) 评论(0) 推荐(0) 编辑