Why my code is not passing the test cases

hello @anshulgurawalia

a) build ur sieve only once, u r bulding new sieve for every new test case due to which ur program is slow

b) also u need to prepare ur sieve atleast of size 10^6+1

i have change my code as you said but it is doesnot pass 1 test case i think it is due to array declaration as globally please take a look

ur sive size is small , preare ur sieve atleast upto 10^6+1

i have change the size but it doesnot pass the test case please edit my code

check here->https://ide.codingblocks.com/s/429531

now u need to optimise it furthure

store all prime numbers upto 10^6 in some array/vector
and then answer each query in O(1) using that vector

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.