Could someone help me in solving this problem : https://www.codechef.com/LOCMAY18/problems/DSERIES ? Here is my solution which, obviously, TLE'ed : https://www.codechef.com/viewsolution/18677401 . Also, it would be great if you could point me to some, other similar problems. Thanks!