only one test case is failingā¦please tell me the test case
#include
#include
using namespace std;
#define ll long long
void nthprime(int *p)
{
// make all the odd numbers prime
for (int i = 3; i <= 500000; i += 2)
{
p[i] = 1;
}
for (ll i = 3; i <= 500000; i += 2)
{
if (p[i] == 1)
{
for (ll j = i * i; j <= 500000; j = j + i)
{
// change all the divisors of all the odd numbers to not prime
p[j] = 0;
}
}
}
// corner cases
p[0] = p[1] = 0;
p[2] = 1;
}
int main()
{
int n;
cin >> n;
int p[500000] = {0};
nthprime§;
vector prime;
for (int i = 0; i < 500000; i++)
{
if (p[i] == 1)
{
prime.push_back(i);
}
}
cout<<prime[n-1]<<endl; return 0;
}