Weight weighing problem

zhaozj2021-02-17  41

Theorem: A (1), A (2), A (1), A (2), ... A (M)} }A (i) constituted by M numbers: A (M) = σA (I), where I is 1 to K, then A (1) = 1 and A (J 1) <= 2a (j) 1, J Take 1, 2, .., M-1 (1) is the number of columns as weight sequences. A competent {0,1, .., AM}, any integer weight, any integer weight. In particular, the sequence is the only possible weight sequence when taking the equal sign, and A (J) = 3 ^ (J-1), for J = 1, 2, .., M.

Introduction: The object of weight is n (1), A (2), .. A (M)}, set M = σ3 ^ (i-1), set to M-parts. I from 1 to M, there are three situations: 1) m n, there may be multi-formation, solve (1 formula) and σa (i) = n, where i from 1 to M, all integer sequences.

Proof of theorem: (adequate) Number: When i = 1, A (i) = 1 is obviously established; assuming that i = k is fully incorporated, that is, the first K with satisfying (1) The weight w (k) that can be weighed is satisfied with all integers of 0 <= w (k) <= a (k), then I = k 1, W (k 1) should be weighed, All integers within 0 <= W (k 1) <= a (k 1). The segmentation discussion is as follows: (a) It is obvious to 0 <= W (k 1) <= A (k), it is obvious to be weighed by the first K weight; (b) for A (K)

(Necessary) When I = 1, it is clear that there must be a weight of 1, and when I> 1, it is revealed that if there is a K, it is not established, ie 2a (k) 1 A (K) 1 cannot be used A (k 1) cooperates with weighing. So contradictory, so the necessity is established. Ingestion can also use the number of simplicity of simplicity, here I don't know, typing is too tired :)

According to the above theorem and inference, it is possible to easily obtain an object of the object that is arbitrary N, and the weight of the weight that can be referred to with the M weight can be improved. When n = σ3 ^ (i-1), i from 1 to M, there is unique solution A (i) = 3 ^ (i-1), can be rewritten as a (i) = 2 (σAJ) 1, where J is output directly from 1 to I-1, one cycle is directly output; when N> σ3 ^ (i-1) is not solved; when n <σ3 ^ (i-1) is time, (1) and guarantee σA (i) = n search. Search for recursive search. I don't write the program.

I finally finished, so tired ~~


New Post(0)