Problem 296
Egg Dropping
Hard · 30 pts · Math, Dynamic Programming, Binary Search
Problem
You have E identical eggs and a building with floors 1 to F. There is an unknown floor X: an egg dropped from floor X or higher breaks, and an egg dropped from below X survives and can be used again. It is also possible that no floor breaks an egg. Find the minimum number of drops that always lets you determine X, in the worst case, using the best strategy. Think in reverse: with e eggs and t drops, the number of floors you can fully check is f(t, e) = f(t - 1, e - 1) + f(t - 1, e) + 1 (the drop's floor, plus the floors below if it breaks and above if it survives). Find the smallest t with f(t, E) >= F.
Input
Two integers E and F.
Output
Print the minimum number of drops.
Constraints
1 <= E <= 100; 1 <= F <= 10000
Example input
2 6
Example output
3
Explanation
With 2 eggs and 3 drops, first drop from floor 3. If it breaks, test floors 1 and 2 with the last egg. If not, drop from floor 5, and then from floor 4 or 6 depending on the result. Every case ends within 3 drops, and 2 drops cannot cover 6 floors.