0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-05 02:06:27 +00:00
OI-codes/Luogu/P3383/P3383.cpp

23 lines
470 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, q, k, p, primes[100000005];
bool not_prime[100000005];
int main() {
cin >> n >> q;
for (int i = 2; i <= n; i++) {
if (!not_prime[i]) primes[++p] = i;
for (int j = 1; primes[j] * i <= n; j++) {
not_prime[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
while (q--) {
cin >> k;
cout << primes[k] << endl;
}
return 0;
}