Multiples of 3- Logic

Can anyone give me any hint about the logic needed to be followed in order to solve the problem Multiples of 3 within the time limit? I tried hard to understand some of the accepted solutions like this, but without any success.

1 Like

This problem is supposed to be solved using segment trees. Check the editorial at http://www.codechef.com/wiki/september-2010-contest-problem-editorials.

2 Likes