#include <bits/stdc++.h>
using namespace std;
const int N=3e6+48;
long long inv[N],n,p;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n>>p;
inv[1]=1;
for(int i=2;i<=n;i++)inv[i]=(p-p/i)*inv[p%i]%p;
for(int i=1;i<=n;i++)cout<<inv[i]<<'\n';
return 0;
}
以上为我的 P3811 的求逆元代码,请问为什么逆元结果中会有 0。比如,输入为 20 2023
时,输出:
1
1012
1349
506
1214
1686
0
0
0
607
184
0
0
0
0
0
0
0
0
1315
0 应该是不对的吧?