0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:36:26 +00:00
OI-codes/Luogu/P3811/P3811.cpp

30 lines
438 B
C++

#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 3e6 + 5;
int n, p, inv[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> p;
inv[0] = 0;
inv[1] = 1;
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;
}
return 0;
}