-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuogu_P_3811.cpp
More file actions
55 lines (47 loc) · 1.02 KB
/
Luogu_P_3811.cpp
File metadata and controls
55 lines (47 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
// #pragma GCC optimize("O3", "inline", "omit-frame-pointer", "unroll-loops", \
// "fast-math")
using namespace std;
// Types
#define ll long long
#define int ll
#define float double
// Aliases
#define x first
#define y second
#define endl '\n'
// Math
#define mod(x) ((x + MOD) % MOD)
// Debug
#define dbg(a) cout << "Dbg: " << #a << " = " << a << endl;
// const double eps = 1e-8;
// const int MOD = 1e9 + 7;
const int N = 3e6 + 10;
int n, p;
// const int MAXN = 100000; // 根据需要调整
// int p = 1000000007; // 要求的模数
int inv[N + 1];
void getInverse(int n, int p) {
inv[1] = 1;
for (int i = 2; i <= n; i++) {
inv[i] = (p - p / i) * inv[p % i] % p;
}
}
void solve() {
cin >> n >> p;
getInverse(n, p);
for(int i = 1; i <= n; i++){
cout << inv[i] << endl;
}
}
signed main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}