TLE '15 P5 - Prefix Sum Array

View as PDF

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 256M

Authors:
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

Fax McClad, Croneria's most courageous bounty hunter, often has weird dreams in his sleep. Sometimes, he dreams about his past experiences, and at other times, he has nightmares about problem statements that have no relation to the actual problem.

d received an array of length () with elements numbered from , and he performed the sum operation on it.

The sum operation takes in an array and returns an array . Array has these two important properties:

1. Array and array are equal in length.
2. For all elements , the element satisfies

Unimpressed with the result, d fed the result back in to the sum operation repeatedly, performing the operation () times in total. At this point, d

Suddenly, Fax wakes up! Disturbed by the abstract dream, he asks you to help solve the problem so he can focus on his bounty hunting.

Input Specification

The first line will contain , the number of elements in the array.

The next line will contain the elements , , each separated by a space.

The final line of input will contain , the number of times the sum operation is performed.

Output Specification

The array after performing sum operations on the given array.

Each element should be outputted mod and elements should be separated by a single space.

Sample Input

5
4 2 8 1 1
2

Sample Output

4 10 24 39 55

Explanation for Sample Output

After one sum operation, the array is changed to:

4 6 14 15 16

After the second sum operation, the array is changed to:

4 10 24 39 55