I compiled my code and it was running for all testcases except the first two i couldnt find a problem in my code
Problem in first two testcases
@soul_coder
hello Nikhil,
your code is correct but the issue is with the size of sieve ,ur sieve size should be greater than 5000000th prime number .
#include<bits/stdc++.h>
using namespace std;
bool isPrime[86100000]={};
int prime[5000000],co=0;
void sieve(){
isPrime[0]=isPrime[1]=1;
long long i,j;
for(i=4;i<86100000;i+=2)
isPrime[i]=1;
prime[0]=2;
co++;
for(i=3;i <86100000 ;i+=2){
if(!isPrime[i]){
prime[co++]=i;
for(j=2*i;j<86100000;j+=i)
isPrime[j]=1;
}
}
}
int main(){
sieve();
int n;
cin>>n;
cout<<prime[n-1];
}
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.
thank you it is now working