One test case failing

#include
#define ll long long
using namespace std;

void PrimeSieve(ll *p)
{

for (ll i = 3; i < 100001; i += 2)
{
    p[i] = 1;
}
for (ll i = 3; i < 100001; i += 2)
{
    if (p[i] == 1)
    {
        for (ll j = i * i; j <= 100000; j = j + i)
        {
            p[j] = 0;
        }
    }
}
// Special case
p[2] = 1;
p[0] = p[1] = 0;

}
int main()
{

ll p[100001] = {0};
PrimeSieve(p);
ll primearr[100001];
ll j = 0;
for (ll i = 2; i < 100001; i++)
{
    if (p[i] == 1)
    {
        primearr[j++] = i;
    }
}
int t;
cin >> t;

while (t--)
{
    ll n;
    cin >> n;
    cout << primearr[n - 1]<<endl;
}

return 0;

}

Can you please tell me for which test case my code is failing for.


Have a look at this solution. Hope all your doubts are cleared.

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.