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…


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, SEQUA Problem - CodeChef

The constraints of SEQUA are much more loose and so, even strange solutions like CodeChef: Practical coding for everyone can pass… (Scroll down to the bottom of the solution XD)