mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:36:27 +00:00
parent
8a39ab2e19
commit
5a06e2f5d6
22
Luogu/P3383/P3383.cpp
Normal file
22
Luogu/P3383/P3383.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user