#C13161. Product Except Self
Product Except Self
Product Except Self
Given an array \(A\) of \(n\) integers, your task is to output an array \(B\) such that each element \(B[i]\) is the product of all elements of \(A\) except \(A[i]\). In mathematical terms, \(B[i] = \prod_{\substack{j=0 \\ j \neq i}}^{n-1} A[j]\). The solution must be implemented without using the division operator.
If the input integer \(n\) does not match the number of integers provided in the array, the program should print an error message.
inputFormat
The input is read from stdin. The first line contains an integer (n) which represents the number of elements in the array. The second line contains (n) space-separated integers.
outputFormat
Output to stdout a single line containing (n) space-separated integers where the i-th integer is the product of all the array elements except the element at position i. If the number of integers does not match (n), output an error message.## sample
4
1 2 3 4
24 12 8 6