我觉得第一个是打表过的
by ZhongYuLin @ 2024-03-12 11:46:03
线性筛
```cpp
#include<bits/stdc++.h>
using namespace std;
bool is[100000012];
int p[100000012],cnt,n,q,x;
int main()
{
cin>>n>>q;
for(int i=2;i<=n;i++)
{
if(!is[i])p[++cnt]=i;
for(int j=1;j<=cnt&&i*p[j]<=n;j++)
{
is[i*p[j]]=true;
if(i%p[j]==0)break;
}
}
while(q--)cin>>x,cout<<p[x]<<endl;
}
```
by 52hertz_yh @ 2024-03-22 17:55:23