endl 改成 '\n'
by XeCtera @ 2023-11-06 22:17:32
endl好像会有缓冲区
by zuohan @ 2023-11-06 22:18:17
```cpp
#include<bits/stdc++.h>
using namespace std;
const int N=3000100;
int n,p;
long long inv[N];
int main()
{
ios::sync_with_stdio(false);
cin>>n>>p;
inv[1]=1;cout<<"1"<<endl;
for(int i=2;i<=n;i++) inv[i]=1ll*((p-p/i)*inv[p%i]%p),cout<<inv[i]<<'\n';
return 0;
}
```
by Ehuo_ovo @ 2023-11-06 22:19:01
@[LxSmill](/user/733980) 可以试试这样:
```cpp
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N=3000100;
int n,p;
long long inv[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>p;
inv[1]=1;cout<<"1"<<endl;
for(int i=2;i<=n;i++) inv[i]=1ll*((p-p/i)*inv[p%i]%p),cout<<inv[i]<<'\n';
return 0;
}
```
by ___PatrickChen___ @ 2023-11-06 22:29:32