13.27 Given a precise balance scale where weights can be placed on both the left and right pans, to measure the masses of $1,2, \cdots, n(n \in N)$ grams of $n$ steel balls respectively, what is the minimum number of weights needed?
【Solution】Let $s$ be the number of weights, with their masses being $a_{1}, a_{2}, \cdots, a_{s}$. It is easy to see that numbers of the form $\varepsilon_{1} a_{1}+\varepsilon_{2} a_{2}+\cdots+\varepsilon_{s} a_{s}, \varepsilon_{i} \in\{-1,0,1\}, i=1,2, \cdots, s$ total $3^{s}$, or in other words, there are at most $3^{s}$ distinct numbers. However, one of these is 0, and the rest are evenly split between positive and negative, so the number of positive numbers of this form is at most $\frac{1}{2}\left(3^{s}-1\right)$. Therefore, these $s$ weights can measure at most $\frac{1}{2}\left(3^{s}-1\right)$ different masses. To represent the $n$ masses $1,2, \cdots, n$, it must be that
$$
\begin{array}{l}
n \leqslant \frac{1}{2}\left(3^{s}-1\right), \\
s \geqslant \log _{3}(2 n+1) .
\end{array}
$$

From this, we can see that when $2 n+1$ is a power of 3, at least $s=\log _{3}(2 n+1)$ weights are needed; when $2 n+1$ is not a power of 3, $s=\left[\log _{3}(2 n+1)\right]+1$.

On the other hand, if the masses of the $s$ weights are taken to be $1,3,3^{2}, \cdots, 3^{s-1}$, then the sum of these weights is $\frac{1}{2}\left(3^{s}-1\right) \geqslant n$. Moreover, for any $0<k \leqslant n \leqslant \frac{1}{2}\left(3^{s}-1\right), k$ can be expressed as a linear combination of the first $s$ powers of 3 with coefficients $-1,0,1$. Therefore, these $s$ weights can indeed measure the masses $1,2, \cdots, n$ grams.
In summary, the minimum number of weights needed is $s$:
$$
s=\left\{\begin{array}{l}
\log _{3}(2 n+1), \text { when } 2 n+1 \text { is a power of } 3, \\
{\left[\log _{3}(2 n+1)\right]+1, \quad \text { otherwise. }}
\end{array}\right.
$$