We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a0d14f9 commit 6006676Copy full SHA for 6006676
Template/Inverse_Element/Readme.md
@@ -13,23 +13,23 @@ x / a ≡ x * b (mod M)
13
14
##### 方法1:
15
```
16
-a^-1 ≡ (M- [M/a] )(M%a)^-1(mod M),其中[]是向下取整。
+a^-1 ≡ (M- [M/a] )(M%a)^-1 (mod M),其中[]是向下取整。
17
18
19
##### 方法2:快速幂法
20
根据费马小定理,我们有
21
22
-a^-1 ≡ a ^ (M-2)
+a^-1 ≡ a ^ (M-2) (mod M)
23
24
显然,我们需要利用快速幂来计算这个数。
25
26
##### 方法3:线性求逆元
27
如果我们想求1,2,3...N 每个数的逆元:
28
```cpp
29
-const ll N=1e6+7, mod=998244353;
+const ll N = 1e6+7, M = 998244353;
30
ll inv[N];
31
for(inv[1]=1,i=2;i<N;++i)
32
- inv[i]=(mod-mod/i)*inv[mod%i]%mod
+ inv[i]=(M - M/i) * inv[M % i] % M
33
34
35
#### 逆元的一些性质
0 commit comments