#T245. 鸡蛋的硬度

鸡蛋的硬度

Description

Recently, XX Company held a peculiar competition: the King of Egg Hardness Championship.
The contestants were hens from all over the world, and the competition was about whose eggs were the hardest. What's even stranger is that XX Company didn't use any precision instruments to measure egg hardness. Instead, they adopted an old-fashioned method—dropping eggs from heights—to test the hardness. If an egg laid by a hen doesn't break when dropped from the a-th floor of a building but breaks when dropped from the (a+1)-th floor, then the hardness of that hen's eggs is said to be a.

You could certainly come up with various reasons to argue that this method is unscientific—for example, eggs from the same hen might have different hardness levels, and so on. However, this doesn't affect XX Company's championship because their goal is simply to attract attention. When eggs are dropped one after another from a 100-story building, the spectacle is enough to draw crowds. Of course, XX Company would never forget to hang a banner on the building with the words "XX Company"—this competition is just another unconventional advertisement for them.

Xiao A, who is always thoughtful, can often spot a mathematical problem in any situation, and this was no exception. "If there are many eggs of the same hardness, I can use a binary search approach to determine the hardness with the fewest attempts," Xiao A was quite pleased with this conclusion. But soon, trouble arose. "But what if I don't have enough eggs? For example, if I only have one egg, I'd have to start dropping it from the first floor, one floor at a time. In the worst case, I'd need to drop it 100 times. If I have two eggs, then I should start dropping from the 2nd floor... Wait, no, maybe I should start from the 1/3 point... Hmm, that might not be right either... What about three eggs? Or four, five, or more?" As usual, Xiao A found himself stuck in a mental rut. It's not so much that he's thoughtful as he enjoys making trouble for himself.

Well, since trouble has come, someone has to solve it. Xiao A's trouble is now up to you to resolve :)

Input Format

The input consists of multiple test cases. Each test case is a single line containing two positive integers, n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 10), where n represents the height of the building, and m represents the number of eggs you currently have. These eggs are of the same hardness (i.e., they will either all break or all remain intact when dropped from the same height) and are less than or equal to n.

You can assume that an egg with hardness x will not break when dropped from any height less than or equal to x (eggs that don't break can be reused), and it will definitely break when dropped from any height greater than x.

For each test case, you can assume that the hardness of the eggs is between 0 and n, meaning that dropping an egg from the (n+1)-th floor will always break it.

Output Format

For each test case, output an integer representing the minimum number of attempts required in the worst case when using the optimal strategy.

100 1
100 2


100
14

Hint

The optimal strategy refers to the strategy that minimizes the number of egg drops required in the worst-case scenario.

If there is only one egg, you can only start dropping it from the first floor. In the worst case, if the egg's hardness is 100, you will need to drop it 100 times. If you adopt any other strategy, you may fail to determine the egg's hardness (for example, if you drop the egg from the second floor first and it breaks, you cannot determine whether the hardness is 0 or 1). In this case, the worst-case scenario would require an infinite number of drops. Therefore, the answer for the first set of data is 100.