Question: 1000 bottles of water, one of which is poisonous, a rat drinking poison water will die after a day, there are now a total of 10 mice, how to determine which bottle of water is poisonous water?
Analysis: 2^10=1024, you can consider using binary solution
Solution: To 1000 bottles of water labeled 1 to 1000, 10 mice from right to left into a column, the first bottle of water to the right 1th mouse to drink, 2nd bottle of water let 2nd mouse drink, 3rd bottle of water let 1th, 2 mice drink, then 4th bottle of water let 3rd mice drink,...... The 1000th bottle of water let the first 4,6,7,8,9,10 mouse drink, remember the death of the mouse is 1, the dead mouse is 0, according to the method of binary notation to find this number, we know which bottle is poisonous water
This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1722548
C Language: 1000 bottles of water, a bottle is poisonous, there are a total of 10 mice, how to judge the poison water?