Featherwit022 @ 2024-12-09 19:51:35
#include<iostream>
#include<cstdio>
using namespace std;
bool isPrime[100000005]={1,1};
int prime[10000005],n,q,top;
void fun(){
for(int i=2;i<=n;++i){
if(!isPrime[i])prime[++top]=i;
for(int j=1;j<=top;++j){
if(i*prime[j]>n)break;
isPrime[i*prime[j]]=1;
if(i%prime[j]==0)break;
}
}
}
int main(){
scanf("%d %d",&n,&q);
int k;
fun();
while(q-->0){
scanf("%d",&k);
printf("%d\n",prime[k]);
}
return 0;
}
by xiezt123456 @ 2024-12-09 19:54:50
@Featherwit022空间太大炸掉了
by Featherwit022 @ 2024-12-09 21:00:57
@xiezt123456prime改成了10000还是编译编译错误(´。_。`)