#C5083. Suffix Sum Transformation

    ID: 48693 Type: Default 1000ms 256MiB

Suffix Sum Transformation

Suffix Sum Transformation

Given an array of integers, transform it such that every element \(A[i]\) is replaced by the sum of all elements from \(A[i]\) to the end of the array. Formally, for an array of length \(N\), update each element as \(A[i] = \sum_{j=i}^{N-1} A[j]\). This computation must be performed independently for each test case.

Input consists of multiple test cases. For each test case, the first line contains an integer \(N\) indicating the number of elements in the array, followed by a line with \(N\) space-separated integers.

The output for each test case should be printed on a new line with the transformed array elements (the suffix sums) separated by spaces.

inputFormat

The first line of input contains a single integer \(T\) representing the number of test cases. The description of each test case is as follows:

  • The first line contains an integer \(N\), the number of elements in the array.
  • The second line contains \(N\) space-separated integers representing the array.

outputFormat

For each test case, output a single line containing \(N\) space-separated integers where the \(i\)-th integer is the sum of elements from index \(i\) to \(N-1\) of the input array.

## sample
1
5
1 2 3 4 5
15 14 12 9 5