#t423. 鸡蛋的硬度

鸡蛋的硬度

Egg Hardness

Problem Description

The building has nn floors (numbered 11 to nn), and you have mm eggs with the same hardness.

The hardness of an egg is an integer xx (0≤x≤n0\le x\le n): an egg with hardness xx will never break when dropped from a floor no higher than xx, and will definitely break when dropped from a floor higher than xx; an unbroken egg can be reused. It can be assumed that an egg dropped from floor n+1n+1 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 n,mn,m (1≤n≤1001\le n\le 100, 1≤m≤101\le m\le 10), 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 11 egg, you can only try from the 11st floor upward floor by floor; in the worst case the egg hardness is 100100, requiring 100100 drops. Any other strategy may fail to determine the hardness (e.g. dropping from the 22nd floor first: if it breaks, you cannot distinguish whether the hardness is 00 or 11), in which case the worst case requires infinitely many drops, so the answer for the first test case is 100100.

Constraints

For each test case: 1≤n≤1001\le n\le 100, 1≤m≤101\le m\le 10; time limit 1s, memory limit 1024KiB.