#C8786. Incremental Sum Sequence
Incremental Sum Sequence
Incremental Sum Sequence
You are given an initial array of non-negative integers and two integers \( n \) and \( m \) where \( n \) is the length of the array and \( m \) is the number of operations to perform. In each operation, compute the sum of the current array and append this sum to the array. Your task is to output the final state of the array after performing all \( m \) operations.
Example:
Input: 3 2 1 2 3 Output: 1 2 3 6 12
In the above example, the sum of [1, 2, 3] is 6, which is appended, making the array [1, 2, 3, 6]. Then, the sum of [1, 2, 3, 6] is 12, which is appended to get [1, 2, 3, 6, 12].
inputFormat
The first line contains two integers \( n \) and \( m \) separated by a space, where \( n \) is the length of the initial array and \( m \) is the number of operations.
The second line contains \( n \) space-separated non-negative integers representing the initial array.
outputFormat
Output a single line containing the final state of the array after performing all \( m \) operations. The numbers should be separated by a single space.
## sample3 2
1 2 3
1 2 3 6 12