PROBLEM STATEMENT
A perfect sequence is a sequence such that all of its elements are non-negative integers and the
product of all of them is equal to their sum. For example: {2,2}, {1,3,2} and {0,0,0,0} are
perfect sequences and {4,5,6} and {0,2,-2} are not perfect sequences (4*5*6 is not equal to 4+5+6,
and negative numbers are not allowed by the definition).
You are given a vector seq. Return "Yes" if it is possible to change exactly one element of
seq so that the resulting sequence is perfect. Otherwise, return "No".
DEFINITION
Class:PerfectSequences
Method:fixIt
Parameters:vector
Returns:string
Method signature:string fixIt(vector seq)
CONSTRAINTS
-seq will contain between 1 and 50 elements, inclusive.
-Each element of seq will be between 0 and 1000000000 (10^9), inclusive.
EXAMPLES
0)
{1,3,4}
Returns: "Yes"
If we change the last element to 2, we have {1,3,2}.
1+3+2 = 1*3*2.
1)
{1,2,3}
Returns: "No"
This sequence is already perfect and it is not possible to change exactly one of its elements and
keep it perfect.
2)
{1,4,2,4,2,4}
Returns: "No"
3)
{1000000,1,1,1,1,2}
Returns: "Yes"
It is possible to replace 1000000 with 6 to make the sequence become perfect.
4)
{8}
Returns: "Yes"
It is possible to change the first element to any non-negative number and the sequence will stay
perfect.
5)
{2,0,2}
Returns: "No"
Note that {2,0,-2} is not considered a perfect sequence because negative numbers are not allowed
by the definition.
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.