Deepak and Primes 2

I think my code is correct but i am getting only 2 testcases correct. Here’s my code:

U`ll have to use segmented sieve since the constraints are for 10^9
which cannot be handled by sieve

i have corrected the code


but this gives tle for 2 cases this is simple sieve implementation
u`ll have to understand segmented sieve to remove tle

Hi, If you see my code I have used Segmented Sieve only. Please see to it once. Thanks

line 42 peh
make p as size 10^9
then it will work fine
baki segmented sieve ka code dekh lo.

Not working when I change the size

Hi @sm26175
I am not able to access the question
some problem with hackerblock

i am not able to check the correctness of the code so i am unable to share it with u
either make size of p as 1000000

i am sharing these code by my fellow TA but i am not sure of it correctness.


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.