Example 2-23 If there are 3 weights of 1 gram, 4 weights of 2 grams, and 2 weights of 4 grams, try to determine which weights can be measured, and how many ways there are to measure each.
$$
\begin{aligned}
G(x)= & \left(1+x+x^{2}+x^{3}\right)\left(1+x^{2}+x^{4}+x^{6}+x^{8}\right)\left(1+x^{4}+x^{8}\right) \\
= & \left(1+x+2 x^{2}+2 x^{3}+2 x^{4}+2 x^{5}+2 x^{6}+2 x^{7}+2 x^{8}\right. \\
& \left.+2 x^{9}+x^{10}+x^{11}\right)\left(1+x^{4}+x^{8}\right) \\
= & 1+x+2 x^{3}+3 x^{4}+3 x^{5}+4 x^{6}+4 x^{7}+5 x^{8}+5 x^{9} \\
& +5 x^{10}+5 x^{11}+4 x^{12}+4 x^{13}+3 x^{14}+3 x^{15}+2 x^{16} \\
& +2 x^{17}+x^{18}+x^{19}
\end{aligned}
$$

Taking the $5 x^{11}$ term as an example to illustrate that there are 5 ways to weigh 11:
$$
111224,11144,12224,11144,1244 .
$$

Weights exceeding 19 grams cannot be measured with the balance.
$$