#K91402. Product Except Self
Product Except Self
Product Except Self
Given an array of integers, your task is to compute a new array output such that each element output[i] is equal to the product of all the numbers in the original array except the one at index i. More formally, if the input array is given by \(a_0, a_1, \dots, a_{n-1}\), then for each valid index \(i\), the output should satisfy:
\(output[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} a_j\)
Note: Do this without using division. The input will be provided via standard input (stdin) and the result should be output to standard output (stdout) as a sequence of space-separated integers.
inputFormat
The first line of input contains a single integer \(n\), representing the number of elements in the array. The second line contains \(n\) space-separated integers, which are the elements of the array. If \(n = 0\), the second line will be empty.
outputFormat
Output a single line containing \(n\) space-separated integers, where the \(i\)th integer is the product of all the elements of the array except the element at position \(i\). For an empty array, output an empty line.
## sample4
1 2 3 4
24 12 8 6