码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Poor Pigs 可怜的猪

时间:2017-10-14 01:21:42      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:nbsp   minimum   mount   within   contains   for   out   amount   water   

 

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 bucket contains the poison within one hour.

Answer this question, and write an algorithm for the follow-up general case.

Follow-up:

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 "poison" bucket within p minutes? There is exact one bucket with poison.

 

s

 

[LeetCode] Poor Pigs 可怜的猪

标签:nbsp   minimum   mount   within   contains   for   out   amount   water   

原文地址:http://www.cnblogs.com/grandyang/p/7664088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!