逆元定义:若a*x=1(mod p),(a,p互质),则x为a mod p意义下的逆元
做法见https://www.luogu.org/blog/zjp-shadow/cheng-fa-ni-yuan
#include<cstdio>
using namespace std; int inv[],p; int main(){
int n,p;
scanf("%d%d",&n,&p);printf("1\n");inv[]=;
for(int i=;i<=n;i++){
inv[i]=(-1LL*(p/i)*(inv[p%i]))%p;
inv[i]=((inv[i]%p)+p)%p;
printf("%d\n",inv[i]);
}
}