title

乘法逆元

#include<cstdio>
#define int long long
using namespace std;
const int N =3000010;
int n,p,inv[N];
signed main(){
	scanf("%d%d",&n,&p);
	inv[1]=1;printf("1\n");
	for(register int i=2;i<=n;++i){
		inv[i]=((-p/i*inv[p%i])%p+p)%p;
		printf("%d\n",inv[i]);
	}
	return 0;
}
posted @ 2018-09-10 01:36  Horrigue_JyowYang  阅读(98)  评论(0编辑  收藏  举报