#C4660. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array \(A\) of n integers, compute a new array \(B\) such that for each index \(i\),
\(B[i] = \prod_{j \neq i} A[j]\). In other words, each element in the resulting array is the product of all the numbers in the original array except the one at that index.
If the array contains only one element, output 0.
This problem requires you to compute the products efficiently without using division.
inputFormat
The input is given from standard input (stdin). The first line contains a single integer \(n\) (the number of elements). The second line contains \(n\) integers separated by spaces.
outputFormat
Print the resulting array to standard output (stdout) as \(n\) integers separated by spaces.
## sample4
1 2 3 4
24 12 8 6