#K43537. Product of All Elements Except Current
Product of All Elements Except Current
Product of All Elements Except Current
Given an integer array ( A = [a_1, a_2, \ldots, a_n] ), you are to compute a new array ( B ) where each element ( B[i] ) is equal to the product of all elements of ( A ) except ( a_i ). Formally, ( B[i] = \prod_{\substack{1 \leq j \leq n \ j \neq i}} a_j ). Note that if the array has only one element, the result should be an empty output.
inputFormat
Input is read from standard input. The first line contains a single integer ( n ) (the number of elements). The second line contains ( n ) space-separated integers representing the array.
outputFormat
Output the resulting array on a single line, with each product separated by a space. If ( n \leq 1 ), output nothing.## sample
1
1