TopCoder problem "MultiNumber" used in SRM 422 (Division II Level One)



Problem Statement

    A number is a multi number if its decimal representation can be split into two numbers, such that the product of all the digits in the first number is equal to the product of all the digits in the second number. For example, 1221 is a multi number because it can be split into 12 and 21, and 1 * 2 = 2 * 1. 1236 is also a multi number, but 1234 is not. Note that you can only split a number into two sequences of consecutive digits, where each sequence contains at least one digit. So, for example, we can only split 12345 in four different ways: 1-2345, 12-345, 123-45, 1234-5. You will be given an int number. Return "YES" if it is a multi number, or "NO" otherwise (all quotes for clarity).
 

Definition

    
Class:MultiNumber
Method:check
Parameters:int
Returns:String
Method signature:String check(int number)
(be sure your method is public)
    
 

Constraints

-number will be between 1 and 2,147,483,647, inclusive.
 

Examples

0)
    
1
Returns: "NO"
Note that all single-digit numbers are not multi numbers. That's because they cannot be split into two non-empty parts.
1)
    
1221
Returns: "YES"
Example from the problem statement.
2)
    
1236
Returns: "YES"
3)
    
4729382
Returns: "NO"
4)
    
42393338
Returns: "YES"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10072

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13513&pm=10072

Writer:

mateuszek

Testers:

PabloGilberto , Olexiy , ivan_metelsky , ged

Problem categories:

Math