WA IN PRIME1

Why this code http://ideone.com/3puswp giving RTE for this question… PRIME1 Problem - CodeChef

I implemented using segmented seive.

Problem is with the below mentioned statement in the sieve function:

mark[i*j]=1; // i goes til 10^6 and so does j in your code. Hence, max(i*j)=10^12 thus giving RTE.
3 Likes

I changed the code this way, can you please see to the mistake in this one 7Hk5mh - Online C++ Compiler & Debugging Tool - Ideone.com . Its really going above now… i tried so many test cases, but repeatedly giving WA.

You cannot read the number up to 10^12 in int

2 Likes

@betlista it still gives WA!!!