5. In the number $2 * 0 * 1 * 6 * 0 * 2 *$, each of the 6 asterisks needs to be replaced with any of the digits $1,2,3,4,5,6,7,8,9$ (digits can repeat) so that the resulting 12-digit number is divisible by 18. In how many ways can this be done
Answer: 26244.

Solution. For a number to be divisible by 18, it is necessary and sufficient that it is divisible by 2 and by 9. To ensure divisibility by 2, we can choose the last digit from the available options as $2, 4, 6$ or 8 (4 ways).

To ensure divisibility by nine, we proceed as follows. We select four digits arbitrarily (this can be done in 9.9 .9 .9 ways), and then choose the fifth digit so that the sum of all the digits of the number is divisible by 9. Since these digits give all possible remainders when divided by $9 (0,1,2, \ldots, 8)$, and each remainder occurs exactly once, the last digit can be chosen in one way.

Applying the rule of product, we get that the total number of ways is $4 \cdot 9 \cdot 9 \cdot 9 \cdot 9 \cdot 1=26244$.