in the deepak and primes problem on hackerblocks https://hack.codingblocks.com/contests/c/669/700
we are asked to tell the 5000000th prime number also, how do i know that what size of array should i take for prime sieve? because i dont know where it will come.
if it would say to print the prime less than 5000000, then it can be easily done by taking same size array.
but how to find this thing? there must be some logic…
How to determine the number of primes till a certain number?
Raghav, you have to solve this question using prime seive logic only, use
long long int N=90000000;
long long int p[N];
primeseive(p,N);
call this function only once before you take input of a and b, and use counter for the same
This is ok. I know what number to take. But my question is that how U got to know that this number should be taken? Is there any logic? Or hit and trial or Google search…
I future, how will i know that in case of sone other problem?
Raghav generally in the constraints its mentioned regarding the size which needs to be taken , and sometimes when your code is showing runtime error, then its mainly because of these size constraints only