Jun 13, 2022
In Welcome to the Arts Forum
This is a very classic Tencent interview question, which may not be unfamiliar to programmers, but for students who see this question for the first time, it will indeed be more brain-burning. In addition to explaining how to solve this problem today, I hope category email list to introduce the concept of information theory to everyone , so in the future, whether you encounter problems such as testing poison or weighing the ball, it will be a small case! Some people may say that I can category email list use 100 mice to find out which bottle of poison is, so is the guinea pig tricking you or provoking you, and has to catch up with a whole family to find poison for you. In fact, the answer to this question is very simple, we only need 7 mice , and the key to solving this problem is the binary in mathematical category email list coding. 1. How to use 7 mice to find poison - binary coding Step1: We encode 100 bottles from 1 to 100, and then convert them into 7-bit category email list binary codes (as to why it is 7 bits, you will understand when you see it later) . For example, bottle No. 1 is converted to "0000001", and bottle No. 10 is converted to "0001010": Step2: Find 7 mice and number them from 1 to 7 respectively. For the mouse with number 1, feed it all the bottles whose binary code is 1 in the first digit (counting from left to right); for the mouse with number. Feed it all the bottles with the second binary code (counting from left to right) A bottle of 1; and so on... Step3: The next step is to see which category email list mice died after a day: if a certain number of mice died, it means that the binary code of the poison bottle's binary category email list code at the corresponding number position is 1; otherwise, if a certain code of mice does not Die, that means the binary code of the poison bottle has a binary value of 0 at the corresponding number position. If the last rat is 2, 3, 5, and 7, it means that the binary code of the corresponding poison bottle is "0110101", which is converted into decimal, that is, the 53rd bottle is poison.