http://www.codechef.com/problems/PRIME1. Hey I am getting wrong answer for PRIME1.http://ideone.com/PvZdWC . Here is my solution. I can’t find the bug. I have first generated all the primes upto sqrt(10^9). Then I take input m and n. And I use segment sieve. I do not know where I am going wrong as I have tasted so many cases where the code is right yet its not being accepted. Please help thanks!

Hey I have solved the bug. It was in the array size of isprime which needs to be 100001 because in the for loop i am taking 0 to less than n-m+1 so for difference of 100000 i would need for loop form 0 to less than 100001 which means needing array size 100001. Hope this helps

1 Like