Deepak and primes

getting tle for even small inputs .I have first mark all primes till 10^8 using seive and then answer the query.
ide: https://ide.codingblocks.com/s/230844

@Vishal123 you are code is passing all test cases in hacker block ide,try submitting your answer once ,maybe there is some error in coding block ide

is there any other method to solve this question . as on other online complier it gives tle

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.