Time limit for one test case(Prateek loves candy)

#include
#define ll long long int
using namespace std;
bool sieve[100000001];
int main() {
sieve[0]=sieve[1]=1;
for(ll i=2;ii<=100000000;i++)
if(!sieve[i])
for(ll j=i
i;j<=100000000;j+=i)
sieve[j]=1;
ll N,t;
cin>>t;
while(t–)
{
cin>>N;
ll counter=1;
while(N && counter<100000000)
{
counter++;
if(!sieve[counter])
N–;
}
cout<<counter<<endl;
}
}

Hi @shivansh.sm1
You are facing TLE in one case because for large values of n and t you are again and again traversing the seive array to find nth prime number. So to avoid this you can do one thing that is take an array and store each nth prime number in that array and in the while loop of test case just print prime[i].

Here is your corrected code :

If your doubt is clear then mark it as resolved.