linrun0504 @ 2024-09-15 19:31:29
#include<bits/stdc++.h>
using namespace std;
bool prime[1000001];
int c[1000001];
int main(){
int n,q,s,cnt;
cin>>n>>q;
prime[1]=1;
for(int i=2;i*i<=n;i++){
if(prime[i]==false){
for(int j=i;j*i<=n;j++){
prime[j*i]=true;
}
}
}
for(int i=1;i<=n;i++){
if(prime[i]==false){
c[++cnt]=i;
}
}
for(int i=1;i<=q;i++){
cin>>s;
cout<<c[s]<<"\n";
}
return 0;
}
样例对了
by linrun0504 @ 2024-09-15 19:33:32
数组开小了
B~~~
差2个0
by ni_ju_ge @ 2024-09-15 19:34:40
求关