Here is the code , it is modified version of segmented sieve .
Getting right answer but tle in two test cases
Deepak and Primes questions .
@aryan_007 You are calculating the segmented_seive for each query and it takes more time than constant time. Follow these steps to get an AC.
- make a seive array once then precompute all the primes .
2.Find the prefix array.
3.Answer each query in just constant time.
This is the intended solution for this problem.
I hope this helps.
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.