-->
当前位置:首页 > 题库

PROGRAMMING:Poisonous wine geometry

Luz5年前 (2021-05-10)题库412
One bottle of 1000 bottles of wine is poisonous, and the drinker will die within 10 minutes (it has nothing to do with the quantity). Now we consider using as few mice as possible to test the poison. Scheme A: the wine is divided into two parts, one for rat 1 to drink, and one for rat 2 to drink, and then two parts for rat 1 to drink, and one for rat 2 to drink, and one for rat 2 to drink, and then 10 rats are enough. However, 100 minutes is too long, upgrade to scheme B: take two large portions of wine, let rats drink one portion, then divide the two portions into four portions, take two portions for rats to drink two portions, then divide the four portions into eight portions, take four portions for rats to drink three portions,... In this way, 1000 bottles of wine, 10 rats 10 + minutes is feasible. Finally, easy to operate implementation scheme C is formed: rat 1 drinks one bottle every other, rat 2 drinks two bottles every other, rat 3 drinks four bottles every four bottles, rat 4 drinks eight bottles every eight bottles,... (in the form of binary code, 1 means drinking, 0 means not drinking).
According to the given number of mice that died after drinking, the program calculates which bottle of poisonous wine is (the number of wine is 1, 2, 3... And the number of mice is also 1, 2, 3,...).
###Input format:
A string: a comma separated sequence of positive integers (valid range of dead rat numbers). Disorder, there may be repetition. If it is empty string, it means that no rat died (wine is non-toxic).
###Output format:
A whole number: the number of poisonous wine (which bottle of wine is poisonous, output 0 if none).
###Input example:
```in
3,7,9,1,5,3,2
```
###Output example:
```out
three hundred and forty-three
```







answer:If there is no answer, please comment