2022-10-28 01:39:07 +00:00
|
|
|
#include <iostream>
|
2020-11-05 12:57:12 +00:00
|
|
|
|
2022-10-28 01:39:07 +00:00
|
|
|
using std::cin;
|
|
|
|
using std::cout;
|
|
|
|
const char endl = '\n';
|
2020-11-05 12:57:12 +00:00
|
|
|
|
2022-10-28 01:39:07 +00:00
|
|
|
const int N = 3e6 + 5;
|
|
|
|
|
|
|
|
int n, p, inv[N];
|
2020-11-05 12:57:12 +00:00
|
|
|
|
|
|
|
int main() {
|
2022-10-28 01:39:07 +00:00
|
|
|
std::ios::sync_with_stdio(false);
|
|
|
|
cin.tie(nullptr);
|
|
|
|
|
|
|
|
cin >> n >> p;
|
|
|
|
|
2020-11-05 12:57:12 +00:00
|
|
|
inv[0] = 0;
|
|
|
|
inv[1] = 1;
|
2022-10-28 01:39:07 +00:00
|
|
|
|
|
|
|
cout << inv[1] << endl;
|
|
|
|
|
|
|
|
for (int i = 2; i <= n; i++) {
|
|
|
|
inv[i] = p - static_cast<long long>(p) / i * inv[p % i] % p;
|
|
|
|
|
|
|
|
cout << inv[i] << endl;
|
2020-11-05 12:57:12 +00:00
|
|
|
}
|
2022-10-28 01:39:07 +00:00
|
|
|
|
2020-11-05 12:57:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|