fork download
  1. #pragma GCC optimize("O3","unroll-loops")
  2. #include <bits/stdc++.h>
  3. #define ll long long
  4. using namespace std;
  5.  
  6. const int LIMIT = 180000000;
  7.  
  8. int main(){
  9. ios::sync_with_stdio(false);
  10. cin.tie(nullptr);
  11.  
  12. freopen("QUYLUAT.INP", "r", stdin);
  13. freopen("QUYLUAT.OUT", "w", stdout);
  14.  
  15. int n;
  16. cin >> n;
  17.  
  18. vector<bool> isPrime(LIMIT + 1, true);
  19. vector<int> primes;
  20.  
  21. isPrime[0] = isPrime[1] = false;
  22.  
  23. for (int i = 2; i <= LIMIT; i++){
  24. if (isPrime[i]) primes.push_back(i);
  25.  
  26. for (int p : primes){
  27. if (1LL * i * p > LIMIT) break;
  28. isPrime[i * p] = false;
  29. if (i % p == 0) break;
  30. }
  31.  
  32. if ((int)primes.size() >= n) break;
  33. }
  34.  
  35. ll p = primes[n - 1];
  36. cout << 1LL * p * p + n;
  37.  
  38. return 0;
  39. }
  40.  
Runtime error #stdin #stdout 0.04s 25608KB
stdin
Standard input is empty
stdout
Standard output is empty