Description

You have k identical eggs and n floors. Find the minimum number of moves needed to determine with certainty what the critical floor f is (the minimum floor from which an egg breaks when dropped).

Examples

Input:k = 2, n = 6
Output:3
Explanation:

Drop from floor 3: if breaks, test 1,2 with 1 egg (2 moves). If not, test 5,6 similarly. Worst case: 3 moves.

Input:k = 1, n = 10
Output:10
Explanation:

With 1 egg, must test floors 1,2,3...10 sequentially. If egg breaks, can't test higher floors. Worst case needs all 10.

Input:k = 4, n = 8
Output:4
Explanation:

With 4 eggs, binary-like search: drop at 4, then 2 or 6, then narrow down. 4 eggs allow halving each time for 8 floors.

Constraints

  • 1 ≤ k ≤ 100
  • 1 ≤ n ≤ 10⁴

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!