Skip to content

Commit 6006676

Browse files
authored
Update Readme.md
1 parent a0d14f9 commit 6006676

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Template/Inverse_Element/Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ x / a ≡ x * b (mod M)
1313

1414
##### 方法1:
1515
```
16-
a^-1 ≡ (M- [M/a] )(M%a)^-1(mod M),其中[]是向下取整。
16+
a^-1 ≡ (M- [M/a] )(M%a)^-1 (mod M),其中[]是向下取整。
1717
```
1818

1919
##### 方法2:快速幂法
2020
根据费马小定理,我们有
2121
```
22-
a^-1 ≡ a ^ (M-2)
22+
a^-1 ≡ a ^ (M-2) (mod M)
2323
```
2424
显然,我们需要利用快速幂来计算这个数。
2525

2626
##### 方法3:线性求逆元
2727
如果我们想求1,2,3...N 每个数的逆元:
2828
```cpp
29-
const ll N=1e6+7, mod=998244353;
29+
const ll N = 1e6+7, M = 998244353;
3030
ll inv[N];
3131
for(inv[1]=1,i=2;i<N;++i)
32-
inv[i]=(mod-mod/i)*inv[mod%i]%mod
32+
inv[i]=(M - M/i) * inv[M % i] % M
3333
```
3434

3535
#### 逆元的一些性质

0 commit comments

Comments
 (0)