COCI '14 Contest 1 #1 Prosjek

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Mirko is practicing arithmetic operations in an interesting way during math class. First, he writes a sequence of integers A. Then, underneath the first sequence, he writes another sequence of integers B which he gets by replacing every number from the sequence A with the average value of all the numbers before the current one, including it.

For example, if the first sequence of integers A is equal to

\displaystyle  1, 3, 2, 6, 8

then the second sequence of integers B is going to be

\displaystyle  \frac{1}{1}, \frac{1+3}{2}, \frac{1+3+2}{3}, \frac{1+3+2+6}{4}, \frac{1+3+2+6+8}{5}

in other words

\displaystyle  1, 2, 2, 3, 4

You are given the second sequence of integers B. Determine the first sequence of integers A to check Mirko's calculations.

Input

The first line of input contains the integer N (1 \le N \le 100), the length of sequence B.
The second line of input contains the sequence of N spaced-separated integers B_i (1 \le B_i \le 10^9).

Output

The first and only line of output must contain a sequence of N space-separated integers A_i.
Please note: The input data will be such that the elements from the sequence A are integers (1 \le A_i \le 10^9).

Sample Input 1

1
2

Sample Output 1

2

Sample Input 2

4
3 2 3 5

Sample Output 2

3 1 5 11

Sample Input 3

5
1 2 2 3 4

Sample Output 3

1 3 2 6 8

Explanation of Output for Sample Input 3

Look at the task description.


Comments


  • -1
    EdwinYang  commented on Aug. 12, 2020, 1:30 p.m.

    Are the example outputs wrong? for the second output, would the integers not be 3, (3+2)/2, (3+2+3)/3, (3+2+3+5)/4? So 3, 2.5, 8/3, 13/4?


    • 0
      maxcruickshanks  commented on Aug. 12, 2020, 5:11 p.m.

      No, the example outputs do not contain errors; you are trying to obtain an array that would result in sample input if you performed the above operation.


      • 0
        EdwinYang  commented on Aug. 12, 2020, 5:29 p.m.

        Oh I'm sorry you're working backwards. Thanks