mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-25 06:51:58 +00:00
P3811 【模板】乘法逆元
R41337330
This commit is contained in:
parent
279c817d86
commit
162d089d41
18
problem/P3811/P3811.cpp
Normal file
18
problem/P3811/P3811.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
long long inv[3000005];
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user