Not a simple sum!!!!

i am trying this question from past few days but it keeps getting TLE.Even the previous solutions are hard to understand.any kind of help is appreciated.Thanks in advanced…
https://www.codechef.com/problems/H4

vijju123

Pay attention to m.

Solution time complexity is O(min(n, m)).

Use geometric series.

PS: I guess you made a mistake in name of this problem. It’s “Just a simple sum”

I havent solved that question yet dear. Perhaps taran can help you at this one :slight_smile:

Someone has already explained a replica of this problem, www.codechef.com/problems/SEQUA

The constraints of SEQUA are much more loose and so, even strange solutions like https://www.codechef.com/viewsolution/14878624 can pass… (Scroll down to the bottom of the solution XD)