Coverain @ 2024-03-14 19:35:48
4个re
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+50;
long long n,m,f[N],k=1;
long long pri[N],ans[N],q;
int e;
bool isp[N];
vector<int> sb;
void gen_prime(int n,vector<int>&prime){
memset(isp,true,sizeof(isp));
for(int i=2;i<=n;++i){
if(isp[i]) {
prime.push_back(i);
ans[k]=i;
k++;
}
for(int p:prime){
if(p*i>n) break;
isp[p*i]=false;
pri[p*i]=p;
f[i]=false;
if(i%p==0) break;
}
}
}
int main()
{
std::ios::sync_with_stdio(0);
cin>>n>>q;
gen_prime(n,sb);
while(q--){
cin>>m;
cout<<ans[m]<<endl;
}
}
by masonxiong @ 2024-03-17 16:24:35
不 re 就见鬼了
数据范围说了
by masonxiong @ 2024-03-17 16:25:15
@Coverain