Skip to content

Commit 820fb41

Browse files
author
taotao
committed
添加解线性同余方程
1 parent 735542b commit 820fb41

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: math/数论算法模板总结.md

+13
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ LL big_mod(string val,LL mod)
137137
return res;
138138
}
139139
```
140+
##模方程
141+
```c++
142+
LL MLE(LL a,LL b,LL n){
143+
LL d,x,y;
144+
d = ex_gcd(a,n,x,y);
145+
if(b%d !=0){
146+
return -1;
147+
}else{
148+
LL x0 = x*b/d%n+n;
149+
return x0%(n/d);//模(n/d)
150+
}
151+
}
152+
```
140153
##乘法逆元
141154
a在模n意义下的逆
142155
```c++

0 commit comments

Comments
 (0)