#K46652. Product of All Other Integers
Product of All Other Integers
Product of All Other Integers
Given an array of integers, 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 index (i). Formally, for an array (A) of length (n), you need to compute for every (i) (where (0 \leq i < n)):
[ B[i] = \prod_{\substack{0 \leq j < n \ j \neq i}} A[j] ]
If the array is empty, return an empty output. If the array has exactly one element, output [1].
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n) representing the number of elements in the array. If (n > 0), the second line contains (n) space-separated integers. For an empty array, (n) is 0.
outputFormat
Print a single line to standard output (stdout) containing the computed product values as space-separated integers. For an empty array, print nothing.## sample
4
1 2 3 4
24 12 8 6