Product
InterviewTime limit1sMemory limit256 MB
Given up to 100,000 integers, decide whether one element equals the product of all the others and print such an element if it exists.
- Level
Medium5 of 10
- Topics
- Math, Array, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
Given a list of numbers, determine whether one of these numbers equals the product of all the other numbers.
Input
The first line of the input file contains a single integer , the number of elements in the initial list (). The next line contains space-separated numbers constituting the list. Each of these numbers is an integer not greater than in absolute value.
Output
In the first line of the output file, print Yes or No, depending on whether some number from the list is equal to the product of all the other numbers or not. If the answer is Yes, in the second line, print such a number. If several numbers satisfy the conditions of the problem, print any of them.