#C2882. Product Except Self
Product Except Self
Product Except Self
Given an array of integers, your task is to compute a new array such that the element at index i is equal to the product of all the numbers in the original array except the number at index i. In other words, for each index i the output should satisfy the formula: \(output[i]=\prod_{j\neq i} a_j\).
The problem requires you to handle edge cases such as when the array contains a single element or when some elements are zero. The input will be provided as a single line on standard input containing the elements separated by spaces, and you should output the result in the same format on standard output.
inputFormat
The input consists of a single line containing space-separated integers. Each integer represents an element of the array.
outputFormat
Output a single line containing space-separated integers where the i-th integer is the product of all the elements of the input array except for the i-th element, i.e. (output[i]=\prod_{j\neq i} a_j).## sample
1 2 3 4
24 12 8 6