0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-28 14:31:58 +00:00

#110. 乘法逆元

https://loj.ac/s/1025514
This commit is contained in:
Baoshuo Ren 2021-01-03 00:01:54 +08:00 committed by Baoshuo Ren
parent 7a684f220c
commit 36b177634a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

18
LibreOJ/110/110.cpp Normal file
View File

@ -0,0 +1,18 @@
#include <bits/stdc++.h>
using namespace std;
long long inv[20000005];
int main() {
inv[0] = 0;
inv[1] = 1;
int n, p;
scanf("%d%d", &n, &p);
printf("1\n");
for (int i = 2; i <= n; ++i) {
inv[i] = (long long)p - (p / i) * inv[p % i] % p;
printf("%d\n", inv[i]);
}
return 0;
}