fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int primes[100000], primecount = 0;
  5. bool isPrime[1000001];
  6.  
  7. int main() {
  8. int N = 1000000;
  9. memset(isPrime, true, sizeof(isPrime));
  10. isPrime[0] = isPrime[1] = false;
  11. for(long long i = 2; i <= N; i++)
  12. if(isPrime[i]) {
  13. primes[primecount++] = i;
  14. for(long long j = i*i; j <= N; j+=i)
  15. isPrime[j] = false;
  16. }
  17. cout << primes[primecount-1] << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
999983