Hi, Only one test case is failing. Can you please tell me what is the issue?

#include <bits/stdc++.h>
using namespace std;
vector primes;

void sieve(long long *p)
{
for (long long i = 2; i <= 500000; i++)
{
if (p[i] == 0)
{
primes.push_back(i);
for (long long j = i * i; j <= 500000; j = j + i)
{
p[j] = 1;
}
}
}
}
int main()
{

long long n;
cin >> n;
long long p[500000] = {0};
primes.push_back(0);
sieve(p);
cout << primes[n];

}

Hey @suhaib0900, instead of running for loop till 500000.
Run it till 700000, it will pass all test cases.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.