对于 ax+by=gcd(a,b) 这样的方程,可以用扩展欧几里得算法exgcd求出一组通解。 根据欧几里得求gcd: gcd(a,b)=gcd(b,a%b) 可得 bx+(a%b)y=gcd(b,a%b) 根据 a%b=a?(a/b)?b 可得 bx+ay?(a/b)b?y=gcd(b,a%b) ...
分类:
编程语言 时间:
2019-08-14 14:51:39
阅读次数:
120
"1187 寻找分数" 思路:类欧几里得 代码: ...
分类:
其他好文 时间:
2019-08-13 13:40:14
阅读次数:
54
There is an interesting and simple one person game. Suppose there is a number axis under your feet. You are at point A at first and your aim is point ...
分类:
其他好文 时间:
2019-08-11 20:44:18
阅读次数:
130
朴素的欧几里得算法大家应该知道 $gcd(a,b)$表示a,b的最大公约数 朴素的欧几里得算法其实就是所谓的辗转相除法 辗转相除法 $gcd(a,b)=gcd(b,a$ $mod$ $b)$ 证明如下: $设r=a$ $mod$ $b$ $=a \lfloor\frac{a}{b}\rfloor b ...
分类:
编程语言 时间:
2019-08-10 21:46:56
阅读次数:
91
The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m). Input ...
分类:
其他好文 时间:
2019-08-10 19:01:38
阅读次数:
95
青蛙的约会 TimeLimit:1000MS MemoryLimit:10MB TimeLimit:1000MS MemoryLimit:10MB 64-bit integer IO format:%lld 64-bit integer IO format:%lld 已解决 | 点击收藏 | 已有3 ...
分类:
其他好文 时间:
2019-08-10 17:19:21
阅读次数:
101
求逆元的四种算法 拓展欧几里得算法求逆元 "上一篇博客中" 已经讲过拓展欧几里得算法,并且讲解了求逆元的原理。这里只列出代码 在要求逆元的数与p互质时使用 代码 c++ //费马小定理 long long q_pow(long long a,long long b,long long p) { lo ...
分类:
编程语言 时间:
2019-08-10 12:02:06
阅读次数:
368
string 操作: GCD : LCM : 扩展欧几里得 : 快速幂 : 矩阵快速幂 : 最长公共子序列LCS : 最短路Floyd : 并查集 : SG 打表 : SG_DFS : ...
分类:
其他好文 时间:
2019-08-07 23:00:43
阅读次数:
195
线性不定方程解法 扩展欧几里得算法: 扩展欧几里得算法: 考虑求这个不定方程的一个解: ax+by=c 二元一次不定方程: 二元一次不定方程: 形如: ax+by=c,a≠0,b≠0 的不定方程称为二元一次不定方程。 n元一次不定方程: n元一次不定方程: 形如: a1x1+a2x2+ ???? + ...
分类:
其他好文 时间:
2019-08-07 09:31:47
阅读次数:
141
前言:刷了几天的数论题目,总结一下 1、拓展欧几里得:求解不定方程ax+by=c【当c%gcd(a,b)≠0时,方程无解】 1 void exgcd(ll a,ll b,ll &d,ll &x,ll &y) 2 { 3 if(!b) x=1,y=0,d=a; 4 else {exgcd(b,a%b, ...
分类:
其他好文 时间:
2019-08-03 21:52:17
阅读次数:
119