Editorial for COCI '14 Contest 1 #1 Prosjek


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Let Sk be the sum of the first k numbers in sequence A. It holds:

Bk=Skk

It follows:

Bk+1=Sk+Ak+1k+1

From here we get the expression for Ak+1:

Ak+1=(k+1)Bk+1Sk

We calculate elements of the sequence Ak+1 and their sum Sk iteratively by using one loop over sequence B.


Comments

There are no comments at the moment.