#K53802. Product of Array Except Self
Product of Array Except Self
Product of Array Except Self
Given an array of integers, compute a new array such that the element at each index is the product of all the numbers in the original array except the number at that index. Formally, for an array a[0...n-1], you need to construct an array result where
$$result[i] = \prod_{\substack{0 \leq j < n \ j \neq i}} a[j]$$
You are not allowed to use division in your solution. The input is given via standard input and the output should be printed on standard output with the products separated by a space.
inputFormat
The first line contains a single integer n
representing the number of elements in the array. The second line contains n
space-separated integers.
outputFormat
Output a single line containing n
space-separated integers, where the ith integer is the product of all array elements except the one at index i.
4
1 2 3 4
24 12 8 6
</p>