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)
CONSTRAINTS
-X will be between 1 and 100,000,000, inclusive.
EXAMPLES
0)
1
Returns: 2
1 is not representable, and 2 = 1 + 1 is representable.
1)
999
Returns: 1000
999 is not representable, and 1000 = 999 + 1 is representable.
2)
2000
Returns: 2000
2000 = 1999 + 1 is representable.
3)
4201234
Returns: 4222222
All numbers between 4201234 and 4222221 are not representable, and 4222222 = 3111111 + 1111111 is
representable.
4)
10101010
Returns: 10102222
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.