I have tried several things, still the following code is giving wrong answer. It works perfectly in ideone and my computer.
Oh great! It was exactly the mistake I was making during the contest but I realized it after a few WAs. The click here is that if your answer overflows 10^9 + 7 at some iteration of the program, then if the value after the condition was supposed to be even, then after mod, it would become odd. (Even mod odd = odd). Just add another variable level (initialized to 1). And after each iteration increment it. It will give AC.
My Code that gave WA:http://www.codechef.com/viewsolution/4708933
Slight Modification which gave AC:http://www.codechef.com/viewsolution/4708980
4 Likes
thanks it worked!
1 Like
I was stuck the same way.
I was also stuck the same way. Thanks
1 Like