Daily

Random

Practice set

Baltic Way 1998 · Problem 20

Combinatorics

We say that an integer mm covers the number 1998 if 1,9,9,81,9,9,8 appear in this order as digits of mm. (For instance, 1998 is covered by 215993698 but not by 213326798 .) Let k(n)k(n) be the number of positive integers that cover 1998 and have exactly nn digits (n⩾5)(n \geqslant 5), all different from 0 . What is the remainder of k(n)k(n) in division by 8 ?

Change pool

When you’re ready

Review material becomes available with the next Daily.

Review

Topics

Pigeonhole and extremal arguments

Solutions

Solution

Solution:

Let 1⩽g<h<i<j⩽n1 \leqslant g < h < i < j \leqslant n be fixed integers. Consider all nn-digit numbers a=a1a2…an‾a = \overline{a_{1} a_{2} \ldots a_{n}} with all digits non-zero, such that ag=1a_{g} = 1, ah=9a_{h} = 9, ai=9a_{i} = 9, aj=8a_{j} = 8 and this quadruple 1998 is the leftmost one in aa; that is,

{al≠1if l<g;al≠9if g<l<h;al≠9if h<l<i;al≠8if i<l<j\begin{cases} a_{l} \neq 1 & \text{if } l < g ; \\ a_{l} \neq 9 & \text{if } g < l < h ; \\ a_{l} \neq 9 & \text{if } h < l < i ; \\ a_{l} \neq 8 & \text{if } i < l < j \end{cases}

There are kghij(n)=8g−1⋅8h−g−1⋅8i−h−1⋅8j−i−1⋅9n−jk_{g h i j}(n) = 8^{g-1} \cdot 8^{h-g-1} \cdot 8^{i-h-1} \cdot 8^{j-i-1} \cdot 9^{n-j} such numbers aa. Obviously, kghij(n)≡1(mod8)k_{g h i j}(n) \equiv 1 \pmod{8} for g=1,h=2,i=3,j=4g = 1, h = 2, i = 3, j = 4, and kghij(n)≡0(mod8)k_{g h i j}(n) \equiv 0 \pmod{8} in all other cases. Since k(n)k(n) is obtained by summing up the values of kghij(n)k_{g h i j}(n) over all possible choices of g,h,i,jg, h, i, j, the remainder we are looking for is 11.

Contest context

Results from Baltic Way 1998

11 teams

Mean score
3.0 / 5
Scores of 4 or 5
5 / 11
Estonia
5 / 5

Score distribution

03
10
21
32
40
55
All team scores
TeamScore
Latvia0 / 5
Estonia5 / 5
Poland5 / 5
Finland0 / 5
St. Petersburg3 / 5
Sweden3 / 5
Denmark5 / 5
Iceland0 / 5
Norway5 / 5
Germany2 / 5
Lithuania5 / 5