rt,代码如下
#include <bits/stdc++.h>
using namespace std;
int n,q,a[100000001];
bool isprime[100000001];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
memset(isprime,1,sizeof(isprime));
isprime[0] = isprime[1] = 0;
for (int i = 2;i <= n;i++){
for (int j = 2*i;j <= n;j += i) isprime[j] = 0;
}
int j = 0;
for (int i = 1;i <= n;i++){
if (isprime[i]){
j++;
a[j] = i;
}
}
while (q--){
int x;
cin >> x;
cout << a[x] << endl;
}
return 0;
}
在此证明没有MLE
