rt,9ms生死距离
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,p,x,y;
inline int read()
{
char ch=getchar();
int x=0,cf=1;
while(ch<'0'||ch>'9')
{
if(ch=='-')
cf=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=(x<<3)+(x<<1)+(ch^48);
ch=getchar();
}
return x*cf;
}
inline void write(int x)
{
if(x==0)
{
printf("%d\n",0);
return;
}
char k[1001];
int t=x>0?x:-x;
int cnt=0;
if(x<0)
putchar('-');
while(t>0)
{
k[++cnt]=t%10+'0';
t/=10;
}
while(cnt>0)
putchar(k[cnt--]);
puts("");
}
inline void exgcd(int a,int b)
{
if(b==0)
{
x=1;
y=0;
return;
}
exgcd(b,a%b);
int t=x;
x=y;
y=t-a/b*y;
}
int main()
{
n=read(),p=read();
for(re int i=1;i<=n;i++)
{
exgcd(i,p);
x=x<0?x+p:x;
write(x);
}
return 0;
}