The Exponential Smoother
Fenwick Mill's control room needs a smoothed reading it can show live, which rules out any average that has to wait for the next few minutes to arrive. The rule the engineers settled on: the display starts at the first reading, and every reading after that drags the display exactly halfway towards itself. Nothing ever drops out of the display — old readings simply count for half as much with each minute that passes.
Task: Print the display value after each reading.
Input
The first line holds an integer n, the number of readings. Each of the next n lines holds one reading.
Output
One line per reading, n lines in all, with exactly two digits after the decimal point. The first line is the first reading itself, there being nothing yet to blend it with.
Example:
Input:
3
10
20
30
Output:
10.00
15.00
22.50
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in