chenhany @ 2024-08-22 21:40:41
#include<bits/stdc++.h>
using namespace std;
bool a[10000001];
long long b[10000001], n, k = 0, f, c[100001];
int main() {
cin >> n;
cin >> f;
for (long long i = 0; i < f; i++) {
cin >> c[i];
}
for (long long i = 2; i <= n; i++) {
if (!a[i]) {
b[k++] = i;
}
for (long long j = 0; k && i * a[j] < n; j++) {
a[b[j]*i] = 1;
if (i % b[j] == 0) {
break;
}
}
}
for (long long i = 0; i < f; i++) {
cout << b[c[i] - 1]<<endl;
}
return 0;
}
by zzhhyy1234 @ 2024-08-25 18:13:56
数组小了