题目地址:Poor Pigs - LeetCode
There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket is poisonous within one hour?
Answer this question, and write an algorithm for the general case.
General case:
If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the poisonous bucket within p minutes? There is exactly one bucket with poison.
Note:
- A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.
- After a pig has instantly finished drinking buckets, there has to be a cool down time of m minutes. During this time, only observation is allowed a

这道LeetCode题目提出了一个数学问题:在1000个桶中,只有一个装有毒药,其余装有水。如果一头猪喝了毒药,它将在15分钟内死亡。目标是在1小时内找出毒药桶。文章探讨了解决这个问题所需的最少猪的数量,并给出了通用情况下的算法。此外,还提供了Python和C++的解题方案。
最低0.47元/天 解锁文章
1328

被折叠的 条评论
为什么被折叠?



