This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 3000010;
//递推打表求逆元
LL inv[N];
void getInv(LL n, LL p) {
inv[1] = 1;
for (int i = 2; i <= n; i++)
inv[i] = inv[p % i] * (p - p / i) % p;
}
int main() {
LL n, p;
cin >> n >> p;
getInv(n, p);
for (int i = 1; i <= n; i++) printf("%d\n", inv[i]); //可以AC
// cout << inv[i] << "\n"; //可以AC
// cout << inv[i] << endl; //这里使用cout就会TLE两个点!
return 0;
}