#C12106. Product Except Self

    ID: 41497 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given an array of integers, compute an output array where each element at index \(i\) is equal to the product of all the numbers in the input array except the one at \(i\). Formally, for an input array nums of length \(n\), you need to construct an output array \(res\) satisfying:

[ res[i] = \prod_{\substack{0 \leq j < n \ j \neq i}} nums[j], \quad 0 \leq i < n. ]

Note: You must not use division in your solution. The input always contains at least one integer.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output a single line with \(n\) space-separated integers, where the \(i\)th integer is the product of all elements of the input array except the \(i\)th element.

## sample
4
1 2 3 4
24 12 8 6