PRIME1-segmented sieve-WA

I have tried for 2 days solving the PRIME1 medium level problem using segmented sieve but am getting wrong answer.Can someone please suggest a clue as to where i am going wrong so that i can rectify that?thanks in advance

here is my code

I am not even able to compiler your code on ideone, see this. . But I am able to compiler and run ideone for all other codes. You can see this however, zO5LFU - Online C++ Compiler & Debugging Tool - Ideone.com
3432 numbers till 10^9 are there which are primes, i added the cout line for displaying that.

1 Like

Read about the Sieve of Eratosthenes! (you will not regret it :))

@damn_me thank you for answering,may be the error is because of the large primes array.I will try to reduce it

@nisargshah95 thanks a lot for the suggestion :slight_smile: I have actually implemented the sieve of eratosthenes in my code in a segmented form as suggested in some sites…could you please help me find the error?