C language: 1000 bottles of water, one of which is toxic. Now there are 10 rats in total. How can we determine the toxic water?
Q: 1000 bottles of water, one of which is toxic. A mouse will die one day after drinking poisonous water. Now there are 10 rats in total. How can I determine which bottle of water is poisonous? Analysis: 2 ^ 10 = 1024, you can consider using the binary solution: to 1000 bottles of water in order to mark 1 to 1000, 10 rats from the right to the left into a column, the first bottle of water let the right side of 1st mice to drink, 2nd bottles of water Let 2nd mice to drink, 3rd bottles of water let the second mouse to drink, then 4th bottles of water Let 3rd mice drink ,...... 1,000th bottles of water in turn let the 4, 6, 7, 8, 9, 10 mice drink, remember the dead mouse is 1, the dead mouse is 0, according to the binary representation of the number method to find this number, you will know which bottle is poisonous water.