Skip to main content
OlympiadHQ

Browse · MathNet

Print

Ukrainian National Mathematical Olympiad

Ukraine counting and probability

Problem

Using each of ten digits exactly once build two numbers (none of them can start with ) so that the absolute value of their difference is smallest possible.

Answer: and .
Solution
It is almost obvious that both numbers should be five-digit, since otherwise their difference will have at least five digits. Indeed, the smallest six-digit number that we can build is , the biggest four-digit number is , and their difference is . For other cases of integers with different number of digits the difference will be even bigger than that.

In order to minimize the difference of two five-digit numbers we should take their first digits to be consequent, because otherwise their difference will also have five digits. Now we need to consider all possibilities when a number with greater first digit is complemented by the minimal digits possible, and the other number is complemented by the maximal digits possible. We see that the minimal possible difference is attained for the numbers and , and is equal to .
Final answer
50123 and 49876

Techniques

Coloring schemes, extremal argumentsCombinatorial optimization