31. Let $f(n)$ denote the number of 0 's in the decimal representation of the positive integer $n$. For example; $f(10001123)=3$ and $f(1234567)=0$. Let
$$
M=f(1) \times 2^{f(1)}+f(2) \times 2^{f(2)}+f(3) \times 2^{f(3)}+\cdots+f(99999) \times 2^{f(09999} .
$$

Find the value of $M-100000$.
31. Answer: 2780
Note that $0 \leq f(n) \leq 4$ for $1 \leq n \leq 99999$. For $k=0,1,2,3,4$, let $a_{k}$ denote the number of integers $n$, where $1 \leq n \leq 99999$, such that $f(n)=k$. Then
$$
M=\sum_{k=0}^{4} k a_{k} 2^{k}=\sum_{k=1}^{4} k a_{k} 2^{k} .
$$

By considering the number of 2-digit, 3-digit, 4-digit and 5-digit positive integers with exactly one 0 in their decimal representation, we obtain
$$
a_{1}=9+9 \times 9 \times 2+9 \times 9 \times 9 \times 3+9 \times 9 \times 9 \times 9 \times 4=28602 .
$$

Similarly, we have
$$
\begin{array}{l}
a_{2}=9+9 \times 9 \times\binom{ 3}{2}+9 \times 9 \times 9 \times\binom{ 4}{2}=4626, \\
a_{3}=9+9^{2} \times 4=333, \\
a_{4}=9 .
\end{array}
$$

Hence
$$
M=1 \times 28602 \times 2+2 \times 4626 \times 2^{2}+3 \times 333 \times 2^{3}+4 \times 9 \times 2^{4}=102780,
$$
and it follows that $M-100000=2780$.