Keywords: binary number, traversal, radix, state value;
I. Introduction to the question
A businessman had a 40-pound weight, which was smashed into four pieces because it fell to the ground. Later, each piece was weighed to a full catty, and these four pieces can be used to weigh any catty between 1 and 40 jins. Ask how much these four pieces cost. Excerpted from "100 Famous Elementary Mathematics Problems"
Two. problem solving
Consider such a problem of weighing by code, which is actually to add and subtract the weights at both ends of the balance to get the target value.
Recursive method can be a good solution:
Let the total mass of the first I fragment be 1 ~ and all the whole pounds can be weighed from this fragment, then+1 fragment is 2+1. Subtract the pounds of the previous block in turn to get (+1) ~ (2+1), and add the pounds of the previous block in turn to get (2+2) ~ (3+1).
2 + 1 — = + 1 2 + 1 + = 3 + 1
2 + 1 — ( — 1) = +2 2 + 1 + ( — 1) = 3
2 + 1 — ( —2) = +3 2 + 1 + ( —2) = 3 — 1
… … … … … …
2 + 1 — 1 = 2 2 + 1 + 1 = 2 + 2
2+1 can of course be weighed out by itself;
So from this fragment of+1, all the integral masses of 1 ~ (3+ 1) can be weighed.
If the weight of the first segment is:
=2 + 1;
=2 1 + 1;
Subtract the two expressions to get = 3;
= 1, so the number of pounds of each fragment is 1, 3, 9, 27 respectively, which meets the requirement that the sum is 40. Third, consider
Any given number is divided into a specific number of values, so that it can traverse 1 to this integer.
A. Changing the number of points in a specific segment can still weight all integer values between 1 and the total number of points.
If the total weight of 42 is divided into 6 pieces, these 6 pieces can weigh the total weight from 1 to 42 pounds. They can
1, 1,4,4 , 16, 16
From the previous special decimal numbers, it can be concluded that the combination of 1, 4, 16 and 0, 1, 2 can get 2( 1+4+ 16).
B. Go back to the beginning of solving the problem. If the value of ≦2+ 1 has more than one possibility,
① ≦, so the previous block can traverse 1, plus 1, 2, 3, etc. To get+1, +2, +3, +4, …,+so you can get+from 1
② ﹤ ≦2 + 1,
-≦+ 1, you can traverse 1 to-
—( — 1)= — + 1
—( —2)= — +2;
… …
—(0) =
+ 1, +2,… … +
So this fragment can reach 1 ~+ all pounds. Answer supplement 4. The minimum number of fragments completes the traversal.
Any integer is decomposed into terms, and its combination can traverse all the values of this number from 1, so the linear combination of ternary and state values can minimize the number of terms and meet the meaning of the question. At the same time, the last term, that is, the score, may not be a power of 3. (1) Among various decimal systems, ternary is the one whose sum increases the most with the increase of the number of items. (2) In other cases, it is necessary to ensure that each number in the traversal is only combined in one of these ways. Otherwise, the ways of constructing the combination will overlap. For example, 42 can be divided into:
1,3,6,27,2
It can also be divided into 1, 1, 4,4, 16, 16.
5. The method of dividing any given number by the least number.
1, write the terms of the given number in turn according to the ternary number until the "score" is not a power of 3. At this point, the number of items is the minimum number of decomposition items. 2. By using the three-point conclusion, as long as ≦2+ 1 is guaranteed, every value can be written without being limited by the power of k. Values are enriched.
An example of 42 is also given: ① Ternary is each base. 1 + 3 + + +… + =
The sum is 1 4 13 40 … leaving a fraction of 2, so the number of ergodic decomposition items is at least five decomposition modes: 1, 3,9,27,22.1,2,7,21,/kloc-0.
1,2,7,20, 12
1,2,6, 18, 15