dev-c++和浴谷ide都过了 record
#include<bits/stdc++.h>
using namespace std;
int n,q,k,Prime[1000005],cnt;
bool isPrime[100000005];
void getPrime(int n){
memset(isPrime,true,sizeof(isPrime));
isPrime[1]=false;
for(int i=2;i<=n;++i){
if (isPrime[i])Prime[++cnt]=i;
for (int j=1;j<=cnt && i*Prime[j]<=n;++j){
isPrime[i*Prime[j]]=false;
if (i%Prime[j]==0)break;
}
}
}
int main(){
scanf("%d %d",&n,&q);
getPrime(n);
while (q--){
scanf("%d",&k);
printf("%d\n",Prime[k]);
}
return 0;
}