#C12850. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array of integers, your task is to compute a new array such that each element at index \(i\) of the new array is the product of all the numbers in the original array except the one at \(i\). In other words, for an input array \( nums \) of length \( n \), the output array \( result \) should satisfy:
\( result[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} nums[j] \)
The input is given from stdin and the output must be printed to stdout as a sequence of space-separated integers. Note that if the input list is empty, you should output nothing. The problem should be solved without using division.
inputFormat
The first line of input contains an integer \( n \) representing the number of elements in the array. If \( n = 0 \), the array is empty. Otherwise, the second line contains \( n \) space-separated integers.
outputFormat
Print a single line containing \( n \) space-separated integers representing the product of all the elements of the array except the element at that index. If the array is empty, output nothing.
## sample4
1 2 3 4
24 12 8 6