Problem Statement |
| Let's call a positive integer A totally odd if each digit in its decimal notation is odd, i.e., one of 1, 3, 5, 7, 9. For example, integers 9, 513, 77777 are totally odd and integers 2 and 99990 are not.
A positive integer N is called representable if it can be represented as N = A + B, where both A and B are totally odd numbers. For example, 2 = 1 + 1 and 4752 = 1377 + 3375 are representable, while 3 and 220 are not.
Given an int X, return the smallest representable number that is greater than or equal to X. |
|
Definition |
| Class: | RepresentableNumbers | Method: | getNext | Parameters: | int | Returns: | int | Method signature: | int getNext(int X) | (be sure your method is public) |
|
|
|
|
Constraints |
- | X will be between 1 and 100,000,000, inclusive. |
|
Examples |
0) | |
| | Returns: 2 | 1 is not representable, and 2 = 1 + 1 is representable. |
|
|
1) | |
| | Returns: 1000 | 999 is not representable, and 1000 = 999 + 1 is representable. |
|
|
2) | |
| | Returns: 2000 | 2000 = 1999 + 1 is representable. |
|
|
3) | |
| | Returns: 4222222 | All numbers between 4201234 and 4222221 are not representable, and 4222222 = 3111111 + 1111111 is representable. |
|
|
4) | |
| |