1 line solution 0ms, with explanation, using C and high school math
\nint poorPigs(int buckets, int minutesToDie, int minutesToTest) {return (int)ceil(log(buckets) / (log(minutesToTest / minutesToDie + 1)));}\n\n\nnotation :\nn 
```\nint poorPigs(int buckets, int minutesToDie, int minutesToTest) {return (int)ceil(log(buckets) / (log(minutesToTest / minutesToDie + 1)));}\n```\n\nnotation :\n```n ^ k = n * n * ... * n``` ( ```k``` times )\n```n! = n * (n - 1) * ... * 1```\n```C(n, k) = n! / (k! * (n - k)!)```\n\nrequired knowledge :\n\nbinominal thoerem : ```(a +b) ^ n = summation (k from 0 to n) ( C(n, k) * a ^ k * b ^ (n - k) )```\n\ndetail:\nhttps://en.wikipedia.org/wiki/Binomial_theorem\n\nFirst, ```minutesToTest``` and ```minutesToDie``` simply tells us how many rounds we can use the pigs, i.e. how many times a pig can eat, that\'s all. So, we can declare a variable called ```r = minutesToTest / minutsToDie```\n\nWe suppose that we have ``` p ``` pigs, now we define ```b(r,p)``` as the maximum amount of buckets that we can test with  ```p```pigs in ```r```rounds, then we try to prove the following result.\n\n**b(r,p) = (r+1)^p**\nor \n```int b(int r,int p){return pow(r+1,p);}```\n\nHere we\'ll use mathematical induction to prove it.\n\nLet\'s start from the case ```r == 1``` \nWith only 1 pig, we can test 2 buckets (make it eat 1 of them, see if it dies.)\nWith 2 pigs ( named as A, B), we can test 4 buckets (one bucket only eaten by A, one only by B, one by both A and B, and one by nobody)\nWith 3 pigs (A, B, C), we can test 8 buckets (O, A, B, C, AB, AC, BC, ABC, this means the buckets are tested by which pigs)\nIn conclusion, We can see that for ```p```pigs, there are ```C(p,k)``` buckets tested by k pigs, so we can test ```C(p,0) + C(p,1) + C(p,2) +... +C(p,p)``` buckets, which is equivalent to ```b(1,p) = 2^p``` by binominal theorem\n\nfor ```r >= 2```, we can have an answer by using the previous result. \nFor ```p```pigs, we can test each bucket with ```0,1,2,...,p``` pigs. If we fix the```k```pigs with whom we\'re going to test the buckets, then we can test up to```b(r-1,p - k)``` buckets. Because if these ```k``` pigs die we\'ll have ```p - k ``` pigs for ```r - 1``` rounds. We can find out which bucket is poisionous among these ```b(r-1, p-k)``` buckets in ```r - 1``` rounds by the definition of ```b(r - 1, p - k)```. Also, we have ```C(p,k)``` combinations for ```k``` pigs among all the ```p``` pigs. Hence, those buckets can be classifed as tested by ```0,1,...,p``` pigs, and there will be at most ```C(p,k) * b(r - 1, p - k)``` buckets tested by ```k``` pigs . Then, we can aquire this result : ```b(r,p) = summation (k from 0 to p) ( C(p,k) * b(r - 1, p - k) )``` by induction hypothesis and ```C(p, k) = C(p, p - k)```, it equals to ```summation (k from 0 to p) ( C(p, p - k) * r ^ (p - k) ) = summation (k from 0 to p) ( C(p, k) * r ^ k * 1 ^ (p - k) ) = (r + 1) ^ p```by binominal theorem.\n\nIn conclusion, we try to find the minimum integer ```p``` such that ```b(r, p) >= buckets```, which is equivalent to ```(r + 1) ^ p >= buckets```, so ```p >= ( log(buckets) / log(r + 1) )```, and here we use the ceiling function and log function provided by ```math.h```, then the return value must be ```ceil( log (buckets) / log (r + 1))```
['Math', 'C']