Deepak and primes

can you please give me a hint how to approach the problem as the constraints are huge .how will we know that upto what value should we iterate to get 500000th prime number

@sjduttabbsr2017
You have to iterate till n = 1e8;
Its just a rough estimate, because you can at most do ~1e8 in 1 sec. and 1e8 works for 500000th prime number.

But we can only build the array or vector upto size 1e6 .how can we iterate till 1e8.Also iterating till 1e6 doesnot give 5000000 th prime number.