刚学线性求逆元,第一次用流输出TLE,第二次就这样了

求问这种re是什么现象,另外为什么会WA,已经用上所有常数优化了
#include<bits/stdc++.h>
#define uLL unsigned long long
//英特纳雄耐尔一定要实现
using namespace std;
const uLL N=1e6+10;
uLL n,p,inv[N];
/*
uLL a,b,x,y;
uLL exgcd(uLL a,uLL b,uLL &x,uLL &y){
if(!b){
x=1;y=0;
return a;
}
uLL d=exgcd(b,a%b,x,y);
uLL z=x;x=y;y=z-y*(a/b);
return d;
}
*/
inline uLL read() {
uLL x=0,w=1;
char ch=0;
while (ch<'0'||ch>'9') {
if (ch=='-') w=-1;
ch=getchar();
}
while (ch>='0'&&ch<='9') {
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}
inline void write(uLL x) {
static uLL sta[35];
uLL top=0;
do{
sta[top++]=x%10,x/=10;
}while(x);
while(top) putchar(sta[--top]+48);
putchar('\n');
}
signed main(){
n=read();
p=read();
/*
exgcd(a,b,x,y);
cout<<(x%b+b)%b;
*/
inv[1]=1;
write(1);
for(register uLL i=2;i<=n;i++){
inv[i]=(p-p/i)*inv[p%i]%p;//公式应当没有问题的罢
write(inv[i]);
}
return 0;
}