有1000只水桶,其中有且只有一桶装的含有毒药,其余装的都是水.它们从外观看起来都一样.如果小猪喝了毒药,它会在15分钟内死去. 问题来了,如果需要你在一小时内,弄清楚哪只水桶含有毒药,你最少需要多少只猪? 回答这个问题,并为下列的进阶问题编写一个通用算法. 进阶: 假设有 n 只水桶,猪饮水中毒后会在 m 分钟内死亡,你需要多少猪(x)就能在 p 分钟内找出“有毒”水桶?n只水桶里有且仅有一只有毒的桶. class Solution(object): def poorPigs(self, bu…
There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucke…
有1000只水桶,其中有且只有一桶装的含有毒药,其余装的都是水.它们从外观看起来都一样.如果小猪喝了毒药,它会在15分钟内死去. 问题来了,如果需要你在一小时内,弄清楚哪只水桶含有毒药,你最少需要多少只猪? 回答这个问题,并为下列的进阶问题编写一个通用算法. 进阶: 假设有 n 只水桶,猪饮水中毒后会在 m 分钟内死亡,你需要多少猪(x)就能在 p 分钟内找出"有毒"水桶?n只水桶里有且仅有一只有毒的桶. 一次喝一个桶的,15分钟后没挂再喝第二桶,一小时60分钟内可以喝 60/15 =…
There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucke…
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如:[Swift]LeetCode156.二叉树的上下颠倒 $ Binary Tree Upside Down 请下拉滚动条查看最新 Weekly Contest!!! Swift LeetCode 目录 | Catalog 序 号 题名Title 难度 Difficulty 两数之…