Hacker Blocks question on Sieve of Eratosthenes(Deepak and Primes)

Test Cases 4,5,6 is giving run-error.Why??

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
const int lim=50000000;
bitset p;
p[0]=p[1]=0;
p[2]=1;
if(n==1)
cout<<2;
else{
int count=1;
for(int i=3;i<=lim;i+=2)
p[i]=1;
for(int i=3;i<=lim;i+=2)
{
if(p[i])
{
count++;
for(int j=ii;j<=lim;j+=2i)
p[j]=0;
if(count==n)
{
cout<<i;
break;
}
}
}
}
return 0;
}

Hey Pratyush, constraints are large for this problem so no.s can be in range of long long int but you have taken the data type as int, that’s why it is giving run time error.

https://ide.codingblocks.com/s/45864
link to my code

Hey Pratyush, error is still the same which i have mentioned earlier. you can store such large numbers in data type int as they are cross the range of int. see line 7 of your code : const int lim=50000000; this number can’t be stored in an int variable.

but even after using long long int test cases 4,5 &6 are giving run-error

check this
https://ide.codingblocks.com/s/46155

Yes its working…Could you please explain how you did it?