SPP SPOJ Problem

Can’t we use the concept of geometric progression to solve this problem?

a(n) can be found out from T^(n-1)*b.
similarly a(m) from T^(m-1)*b.

since we need to find out a(m)+a(m+1)+…a(n).
We can write this sum as :
T^(m-1)*b +T^(m)*b +… +T^(n-1)*b;
which can be further written as [ T^(m-1) + T^(m) + …+T^(n-1) ]b.
Taking T^(m-1) common,we get [ 1+ T+ T^2+ T^3+…+ T^x ] where x=n-m.
using GP we get the sum as [ T^(x+1) -1) ].
We can then further simplify T^(m-1)
[ T^(x+1) -1] = T^n -T^(m-1), as x=n-m.
Finally,
[T^n -T^(m-1)]*b we give us the sum required.

I tried this approach but it did not work. Can you help me find out the logical mistake that i am making?

hello @subhamjaiswal885

the correct Gp FORMULa is
s= a*(r^n-1)/(r-1)

u missed the denominator in ur formula, which is also a matrix.
so u also need to do matrix division and for that u need to find matrix inverse.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.