#C12899. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array A of integers, construct an array B such that each element \(B[i]\) is equal to the product of all elements in A except A[i]. Mathematically, \(B[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} A[j]\). Note: You are not allowed to use division in your solution.
For example, if A = [1, 2, 3, 4], then B = [24, 12, 8, 6].
inputFormat
The first line contains an integer n, which denotes the number of elements in the array. The second line contains n space-separated integers representing the elements of the array A.
outputFormat
Output a single line containing n space-separated integers, where the i-th integer represents \(B[i]\), the product of all elements of A except A[i]. If n is 0, output an empty line.
## sample4
1 2 3 4
24 12 8 6
</p>