#C14029. Product Except Self
Product Except Self
Product Except Self
Given an array of integers, return a new array where the element at each index i is the product of all the numbers in the original array except the one at i. In other words, for each index i, compute:
\(result[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} a_j\)
The input may contain zeros and negative numbers. When the array is empty, simply output nothing.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains an integer n representing the number of elements in the array.
- The second line contains n space-separated integers.
If n is 0, the second line will be empty.
outputFormat
Output the resulting array as space-separated integers on a single line to stdout. If the input array is empty, output nothing.
## sample4
1 2 3 4
24 12 8 6
</p>