Connection Status:
Competition Arena > MultiNumber
SRM 422 · 2008-10-18 · by mateuszek · Math
Class Name: MultiNumber
Return Type: String
Method Name: check
Arg Types: (int)
Problem Statement

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).

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)
1234
Returns: "NO"
4)
808
Returns: "NO"

Submissions are judged against all 72 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class MultiNumber with a public method string check(int number) · 72 test cases · 2 s / 256 MB per case

Submitting as anonymous