## Task 4 - 110614

Two places $A$ and $B$ are connected by a $999 \mathrm{~km}$ long road.

At intervals of $1 \mathrm{~km}$, milestones are placed along this road, each marked on both sides such that one side indicates the distance from $A$ and the other side the distance from $B$ in km. For example, the stone at the exit of $A$ bears the inscription 0 and 999, and the stone at the entrance of $B$ bears the inscription 999 and 0.

Determine the number of these stones whose inscriptions use at most two different digits (e.g., 722 and 277)!
Since the road is 999 km long, the sum of the kilometer readings on each of the stones is 999. It follows that:

(1) On one side of each of the kilometer stones, there is an even number, and on the other side, there is an odd number. Thus, the two numbers are different.

(2) The sum of the units digits on each kilometer stone is 9, as is the sum of the tens digits and the sum of the hundreds digits.

(3) For each kilometer stone \( S \) in the problem, there is exactly one other \( S' \) that has the same digit configuration ( \( S' \) is the same distance from \( B \) as \( S \) is from \( A \)).

The number \( x \) we are looking for is therefore twice the number \( y \) of those kilometer stones whose labeling uses at most two different digits and which are closer to \( A \) than to \( B \). For each such stone \( S \), the hundreds digit of the kilometer reading from \( S \) to \( B \) is one of the digits 5, 6, 7, 8, or 9 (due to (2)).

Therefore, the hundreds digit of the other kilometer reading on \( S \) is 4, 3, 2, 1, or 0, respectively.

In the first four cases, the two digits used are thus determined; but even in the case of 5, no other digit \( z \) can occur except 9 (and possibly 0), because otherwise, the three different digits 9, \( z \), and \( (9-z) \) would appear.

Now, with the digits \( a \) and \( b \), \( b \neq a \), exactly 4 different three-digit numbers can be formed whose hundreds digit is \( a \), namely \( aaa, aab, aba, abb \).

Consequently, since here \( a \) can take the five values 5, 6, 7, 8, 9, and only these: \( y = 5 \cdot 4 \) and the desired number \( x = 2y = 40 \).

Thus, there are exactly 40 kilometer stones whose labeling uses at most two different digits.

Solutions of the I. Round 1971 adopted from [5]

### 3.12.2 II. Round 1971, Class 6