Getting AC but sieve method not working

When I using the basic trial method to find prime, I am getting all correct. But, when I used the segmented sieve method, am getting errors. I calculated primesieve upto 10^5 as the constraint of b is 10^9. Any insights as to why I may be getting TLE for some test cases. isn’t the sieve method supposed to be better?

kindly go though my submissions once

@a_krisna22 as you may have noticed, m-n <= 10^5, but actually the numbers can be as large as 10^9, so for the sieve method you have to calculate the sieve for all 10^9 numbers even if the range is less. You can save your code at ide.codingblocks.com and share the link here.

I understand the numbers can go upto 10^9, but aren’t we supposed to check upto sqrt(max number/10^9) in segmented sieve. PS: I used segmented sieve method, not the normal sieve

https://ide.codingblocks.com/s/200308 just did a optimisation in the iteration of checking multiples, and the code is working fine and just in 0.06 seconds

@a_krisna22 what is the error that you are getting?

its working fine now, I made an optimisation in the iteration of the segment.

@a_krisna22 please mark the doubt as resolved if you are satisfied

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.