diff --git a/Luogu/P3383/P3383.cpp b/Luogu/P3383/P3383.cpp new file mode 100644 index 00000000..2128d0dd --- /dev/null +++ b/Luogu/P3383/P3383.cpp @@ -0,0 +1,22 @@ +#include + +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; +}