Reprinted from: http://blog.csdn.net/zzran/article/details/8083386
The full text is as follows:
This is the application of bit, 1000 is close to 1024, so 10 bit bits are required to number the bottle, from 0 to 999. In this case, 10 mice are required. The bottle numbers are:
000,00000
00000,00001
000,00010,
000,00101
00000,00111
......
11111,00111
At the same time, give the mouse number, starting from 1, 2,... 10, starting from the low level, let the N rats drink the medicine in the n bit as 1 bottle. A week later, if none of the mice had been infected, the first bottle would be toxic. If some mice had been infected, the first bit would be 1, and the other would be 0. After it is changed to an integer, the corresponding number is the number of the toxic potion.
For your own understanding, attach a simple example. If there are four bottles of water, one of which is toxic, you only need two mice according to the above algorithm, for example.
Let the mouse drink all the water from the bottle containing 1 in the column, that is, the right mouse drank 1 or 3 bottles of water, and the left mouse drank 2 or 3 bottles of water, because 1st bottles of water are toxic, then the right mouse is poisoned.
The red is the poisoned mouse, and the white is the normal mouse. Finally, the red mouse is located at the bit position 1, and the white mouse is located at the zeroth, which is a toxic bottle number.