题目:
题解:
class Solution:def poorPigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int:if buckets == 1:return 0combinations = [[0] * (buckets + 1) for _ in range(buckets + 1)]combinations[0][0] = 1iterations = minutesToTest // minutesToDief = [[1] * (iterations + 1)] + [[1] + [0] * iterations for _ in range(buckets - 1)]for i in range(1, buckets):combinations[i][0] = 1for j in range(1, i):combinations[i][j] = combinations[i - 1][j - 1] + combinations[i - 1][j]combinations[i][i] = 1for j in range(1, iterations + 1):for k in range(i + 1):f[i][j] += f[k][j - 1] * combinations[i][i - k]if f[i][iterations] >= buckets:return ireturn 0