偶然看到大神Katoumegumi的欧几里得推导过程,感觉非常接地气。借此收藏。 对于一个方程a?x+b?y=gcd(a,b) 来说,我们可以做如下的推导: 设有a?x1+b?y1=gcd(a,b) ; 同时我们有b?x2+(a%b)?y2=gcd(b,a%b) ; 对于这个方程组,我们希望知道的是 ...
分类:
编程语言 时间:
2019-08-23 00:20:59
阅读次数:
90
"也许更好的阅读体验" 前置知识 快速乘 "扩展欧几里得定理" 同余方程 中国剩余定理(CRT) 目的 求最小的正整数$x$,使其满足 $\begin{cases} x\equiv a_{1}\left( mod\ m\right) \\ x\equiv a_{2}\left( mod\ m_{2} ...
分类:
其他好文 时间:
2019-08-17 18:22:38
阅读次数:
94
对于 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
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
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
若a*b≡1(mod p) 即a,b互为mod p意义下的逆元 即(x/a)%p应为x*b%p 一、扩展欧几里得求逆元 根据a*b+p*k=1 板子O(logN): 1 #include<bits/stdc++.h> 2 typedef long long ll; 3 ll exgcd(ll a,l ...
分类:
其他好文 时间:
2019-07-26 01:14:20
阅读次数:
648