#K73792. Compute Modified Array

    ID: 34054 Type: Default 1000ms 256MiB

Compute Modified Array

Compute Modified Array

You are given an array A of N integers. Your task is to compute a modified array B for each test case such that (B_i = A_i \times C - 1), where (C) is defined as the product of all non-zero elements of A, i.e., (C = \prod_{\substack{j=1 \ A_j \neq 0}} A_j).

If all elements in A are zero, output an array of N values where each value is (-1).

For example, if the input array is [2, 3, 0, 5], then (C = 2 \times 3 \times 5 = 30) and the output array is computed as follows:
(B_1 = 2 \times 30 - 1 = 59),
(B_2 = 3 \times 30 - 1 = 89),
(B_3 = -1) (since A[3] = 0),
(B_4 = 5 \times 30 - 1 = 149).

inputFormat

The input is read from standard input (stdin) and has the following format:

The first line contains an integer T, the number of test cases.
For each test case, the first line contains an integer N, the number of elements in the array A.
The second line contains N space-separated integers representing the array A.

outputFormat

For each test case, print a single line to standard output (stdout) containing N space-separated integers representing the modified array B.## sample

5
4
2 3 0 5
3
0 0 0
5
-1 4 0 -3 2
1
0
1
5
59 89 -1 149

-1 -1 -1 -25 95 -1 -73 47 -1 24

</p>