Xingyi_2014 @ 2024-08-02 13:44:15
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,q,x=0,flag,m;
cin>>n>>q;
int a[10001];
for(int i=0;i<n;i++){
if(i==2)flag=1;
else if(i<2 || i%2==0)flag=0;
else{
for(int j=3;j*j<=i;j+=2){
if(i%j==0){
flag=0;
break;
}
}
}
if(flag==1) {
a[x]=i;
x++;
}
flag=1;
}
for(int i=0;i<q;i++){
cin>>m;
cout<<a[m-1]<<endl;
}
return 0;
}
by ikunTLE @ 2024-08-02 13:57:58
@Xingyi_2014
by Xingyi_2014 @ 2024-08-03 15:22:36
好的