1. A merchant had 4 weights with integer masses. With them, any mass from $1 \mathrm{~kg}$ to $40 \mathrm{~kg}$ can be measured. What are the masses of the weights, if they are all different and their sum is 40?
Solution. We have

$$
40=1+3+9+27=3^{0}+3^{1}+3^{2}+3^{3}
$$

so $40=1111_{3}$ (in base 3 system). Every number from 1 to 40 can be represented in the base 3 system using the digits 0, 1, and 2. Since $2=-1$, it follows that every number can be represented as a number with digits 1 and 0 or as the difference of numbers with digits 1 and 0. Clearly, the number of digits of any number less than 40 is at most 4.

Therefore, the weights of the weights were: $1 \mathrm{~kg}, 3 \mathrm{~kg}, 9 \mathrm{~kg}$ and $27 \mathrm{~kg}$.