#K73847. Modified Array Product
Modified Array Product
Modified Array Product
Given an array \(A\) of integers, modify the array so that each element at index \(i\) is replaced by the product of all elements of \(A\) except \(A[i]\). In other words, for each \(i\), compute
[ result[i] = \prod_{\substack{j=0 \ j \neq i}}^{n-1} A[j] ]
The problem requires that you handle edge cases correctly, including arrays with a single element and arrays that contain one or more zeros.
inputFormat
The input is given in two lines:
- The first line contains a single integer \(n\) (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 is the product of all array elements except the one at position \(i\).
## sample4
1 2 3 4
24 12 8 6