|
9 | 9 |
|
10 | 10 | [Next >](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern "Repeated Substring Pattern")
|
11 | 11 |
|
12 | | -## 458. Poor Pigs (Easy) |
| 12 | +## 458. Poor Pigs (Hard) |
13 | 13 |
|
14 | | -<p>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.</p> |
| 14 | +<p>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?</p> |
15 | 15 |
|
16 | | -<p>Answer this question, and write an algorithm for the follow-up general case.</p> |
| 16 | +<p>Answer this question, and write an algorithm for the general case.</p> |
17 | 17 |
|
18 | | -<p><b>Follow-up: </b></p> |
| 18 | +<p> </p> |
19 | 19 |
|
20 | | -<p>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.</p> |
| 20 | +<p><b>General case: </b></p> |
| 21 | + |
| 22 | +<p>If there are <code>n</code> buckets and a pig drinking poison will die within <code>m</code> minutes, how many pigs (<code>x</code>) you need to figure out the <strong>poisonous</strong> bucket within <code>p</code> minutes? There is exactly one bucket with poison.</p> |
| 23 | + |
| 24 | +<p> </p> |
| 25 | + |
| 26 | +<p><strong>Note:</strong></p> |
| 27 | + |
| 28 | +<ol> |
| 29 | + <li>A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.</li> |
| 30 | + <li>After a pig has instantly finished drinking buckets, there has to be a <strong>cool down time</strong> of <em>m </em>minutes. During this time, only observation is allowed and no feedings at all.</li> |
| 31 | + <li>Any given bucket can be sampled an infinite number of times (by an unlimited number of pigs).</li> |
| 32 | +</ol> |
| 33 | + |
| 34 | +### Related Topics |
| 35 | + [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] |
0 commit comments