代码如下:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#define ll long long
using namespace std;
ll inv[3000006];
int n,p;
void inel()
{
inv[1]=1;
for(int i = 2;i <= n;i++)
{
inv[i]=1ll*(p-p/i)*inv[p%i]%p;
}
}
int main()
{
scanf("%d%d",&n,&p);
inel();
for(int i = 1;i<= n;i++)
{
printf("%lld\n",inv[i]);
}
return 0 ;
}