Hello guys ,

Today i was solving this problem from november cook off : https://www.codechef.com/COOK112B/problems/BIGRES and it gave TLE and i couldnt find a better method to solve the problem

After the contest , i checked some solutions and was literally shocked to know that both of us have almost same code and he got AC and i got WA

Pls let me know how to optimize my approach

Solution : https://www.codechef.com/viewsolution/27932379on

My solution : https://www.codechef.com/viewsolution/27933985

Can someone pls tell me how to optimize my code ?

Thanks !!