A raffle booth's old ticket scanner misreads any printed number containing the digit 0, so the booth never prints a voucher denomination with that digit anywhere in it. Whenever a voucher worth exactly n credits must be split into two smaller vouchers whose credit values add up to n, the booth needs both new denominations to be positive integers with no digit 0 in their decimal representation. Among all such valid splits, the booth always picks the one where the smaller of the two new denominations is as small as possible; once that smallest valid value is fixed, the other denomination is forced, since it must equal n minus the smaller one.
A single line containing one integer n.
Print two integers a and b, separated by a single space, such that a + b = n, both a and b are positive integers with no digit 0 anywhere in their decimal representation, a <= b, and a is the smallest value for which such a split is possible.
2 <= n <= 10000Example 1
Input
11
Expected
2 9
Explanation
The smallest candidate, a=1, would force b=10, but 10 contains a 0 digit, so it is rejected. The next candidate, a=2, forces b=9; neither 2 nor 9 contains a 0 digit, so a=2 is accepted, giving the split '2 9'.
Example 2
Input
1001
Expected
2 999
Explanation
a=1 would force b=1000, which contains 0 digits, so it is rejected. a=2 forces b=999; neither 2 nor 999 contains a 0 digit, so the answer is '2 999'.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →