|
|
вернуться в форумWHY WA#2 #include "bits/stdc++.h" #define int long long using namespace std; vector<int> eratosfen() { int n = 168841; vector<bool> res(n + 1, false); for (int i = 2; i <= n; ++i) { if (!res[i]) { for (int j = i * i; j < n; j += i) { res[j] = true; } } } vector<int> res2; for (int i = 2; i < res.size(); ++i) { if (!res[i]) { res2.push_back(i); } } return res2; } signed main() { int t; cin >> t; vector<int> a = eratosfen(); while (t--) { int n; cin >> n; if (n == 1) { cout << 2; continue; } cout << a[n - 1] << endl; } } Re: WHY WA#2 you should count the eratosphen for a larger n in your function |
|
|