Interview-Mouse Test virus _ algorithm

Source: Internet
Author: User
Tags mixed
The problem with the poison in mice is as follows: There are 1000 vials and 10 mice, 1000 vials have a bottle of poisonous medicine, the other is water. As long as the mice drank the poison, they would die after a while.     Now ask how to use these 10 mice to find out which bottle of poisonous drugs in one lump. The solution of the problem is also very simple: in accordance with the sea of the wrong way to check out the principle of dislocation, in turn, 10 mice into the 1,2,4,8,16,32,64,128,256,512 position, the other place to place small bottles. Each vial is decomposed according to its position into 1,2,4,8,16,32,64,128,256,512 and then to the corresponding position of the mouse to drink.     After a period of time, according to the survival of mice, you can determine which bottle is poison.     For example, if after a period of time, the mouse situation is: 0,0,1,0,1,0,1,1,1,0, (0 of which represent survival, 1 for death), then the poison of the vial of the position is: 0111010100, that is 468, that is the No. 468 place of the vial containing poison. The question is simple.
The problem now is that if the 1000 vials contain 2 bottles of poisonous drugs, then at least how many mice should be needed to find out which two bottles are poison.     This problem is very similar to the above problem, but the sea to check out the dislocation can only correct a dislocation, and can not determine two out of dislocation, then how should do it. For this question, If you have the following assumptions: 1. The higher the concentration of the poison the mice drank, the faster they died; 2. The first vial inside, either water or pure poison; 3. Pure water is mixed with pure water or pure poison, mixed with poison and poison, and purified with poison, which lowers its concentration; 4. If the mice drank the pure poison and the diluted poison, then think     The time of death is the same as that of pure poison, which does not hasten death. So, based on the above assumptions, you can solve this problem: first of all 1000 vials inside the liquid 22 mixed, there are 1000*999/2=499500 bottles of new liquids, this time, the liquid inside only 1 bottles of poison is pure poison, of course, there are some diluted poison, But it doesn't affect the results. Because after a period of time, the first dead mice were drinking this bottle of pure poison mice. This way, you can take advantage of the solution of the simple problem above to solve the problem.          In this case, because of 2^18<499500<2^19, then at least 19 mice needed to detect the bottle of pure poison, and then according to the previous mixed relationship, we know which two bottles are pure poison. Continue to expand your thinking. If there are 3 bottles of poison in the original 1000 bottles, what should we do? With the above analysis, thinking is very simple. The 1000 bottles of liquid 33 mixed, then there is a 1000*999*998/(3*2*1) bottle of new liquid, because the number of 2^27-2^28 between, then at least 28 mice to detect which three bottles of poison, of course, or on the basis of the above 4 hypotheses.
Of course, for 1000 bottles of 4 bottles of poison, 5 bottles of poison, and even more poison, can be based on the above assumptions, using the above method to detect. (Of course, the more points, the more cumbersome the experimenter's work will be, the mere mixing of liquids is troublesome enough.) Hehe: P)
The above idea is based on the original white mouse test poison problem, through the diffusion of thought. Only on the basis of the original sea-plaintext expansion. But I think at this stage, there should be a check code method that can detect 2 or more error bits. If this verification method exists, then the same can be referenced in the test.
If you have any better ways, but also hope that the generous enlighten.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.