sto orz
为什么只有80分?怎么优化?
#include <bits/stdc++.h>
using namespace std;
void exgcd(long long a, long long b, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
return ;
}
long long tx, ty;
exgcd(b, a % b, tx, ty);
x = ty;
y = tx - a / b * ty;
}
int main() {
long long n, p;
cin >> n >> p;
cout << "1\n";
for (int i = 2; i <= n; i++) {
long long x, y;
exgcd(i, p, x, y);
printf("%lld\n", (x % p + p) % p);
}
return 0;
}
sto orz