#t423. 鸡蛋的硬度
鸡蛋的硬度
Egg Hardness
Problem Description
The building has floors (numbered to ), and you have eggs with the same hardness.
The hardness of an egg is an integer (): an egg with hardness will never break when dropped from a floor no higher than , and will definitely break when dropped from a floor higher than ; an unbroken egg can be reused. It can be assumed that an egg dropped from floor will definitely break.
You need to determine the hardness of the eggs by performing several experiments of "dropping an egg from a certain floor and observing whether it breaks". Find the minimum number of experiments required in the worst case.
Input Format
The input contains multiple test cases. Each test case is one line containing two positive integers (, ), representing the building height and the number of eggs, respectively.
Output Format
For each test case, output one line with an integer: the number of egg drops required by the optimal strategy in the worst case.
Sample Input 1
100 1
100 2
Sample Output 1
100
14
Hint
The optimal strategy is the one that minimizes "the number of drops in the worst case".
If there is only egg, you can only try from the st floor upward floor by floor; in the worst case the egg hardness is , requiring drops. Any other strategy may fail to determine the hardness (e.g. dropping from the nd floor first: if it breaks, you cannot distinguish whether the hardness is or ), in which case the worst case requires infinitely many drops, so the answer for the first test case is .
Constraints
For each test case: , ; time limit 1s, memory limit 1024KiB.