Combinations and DP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint fact[10 + 1] = {};\n\nint combinations(int x, int n) {\n  return fact[n] / (fact[n - x] * fact[x]);\n}\n\nint dp[10 + 1][100 + 1];\n\nint states(int x, int t) {\n  if (dp[x][t]) return dp[x][t];\n  if (t == 1) return dp[x][t] = (1 << x);\n  int res = {};\n  for (int i = 0; i <= x; i++)\n    res += combinations(i, x) * states(i, t - 1);\n  return dp[x][t] = res;\n}\n\nstatic const int pre = [](){\n  for (int i = 0, p = 1; i <= 10; i++, p *= i)\n    fact[i] = p;\n  return 0;\n}();\n\nclass Solution {\npublic:\n  int poorPigs(int b, int die, int test) {\n    int p = 0;\n    int t = test / die;\n    while (states(p, t) < b) {\n      p++;\n    }\n    return p;\n  }\n};\n```
['C++']