传送门
对于数论只会gcd的我,也要下定决心补数论了
列出方程
- (x + t * m) % l = (y + t * n) % l
那么假设 这两个式子之间相差 num 个 l,即为
- x + t * m = y + t * n + num * l
经过化简得
- (n m) * t + l * num = x y
那么可以用扩展欧几里得求出结果
——代码
#include <cstdio> #define LL long long inline void exgcd(LL a, LL b, LL &d, LL &x, LL &y) int main()
上一篇:[luoguP2045] 方格取数加强版(最小费用最大流)
下一篇:[luoguP1111] 修复公路(并查集)
数论 扩展欧几里得









