Here's the problem : 227C - Flying Saucer Segments
In the editorial here: http://codeforces.net/blog/entry/5378?locale=en We ended up having F(n) = 3*(F(n-1) + 1) — 1 Could somebody please elaborate on how to get we got ((3^n) — 1) from the recurrence? Sorry if this is a newbie question I'm trying to learn more on the topic.
Auto comment: topic has been updated by Bekh (previous revision, new revision, compare).
Whenever you have a recurrence relation, there is a particular technique to solve it. In this case we have a recurrence in form of F(n) = c1*(F(n-p)+k) + c2, where c1, p(generally equal to 1), k, c2 are The solution to the above recurrence lies entirely into hands if you guess F(n) to be a exponential of contsant c1 +- constant k. So we are very likely to guess the function F(n) as ( c1^n + c3 ) where c3 is a new constant. Then you just have to put the assumed value of F(n-p) in the original equation of F(n) and compare the coefficients.
In this case it is pretty easy to guess that the coefficient of exponentiation will be equal to 3 and value of c3 comes out to be -1. Hope this helps. For further assistance please refer C.L.R.S. chapter 4.