atcoder#CODEFESTIVAL2016FINALE. Cookies
Cookies
Score : points
Problem Statement
Rng is baking cookies.
Initially, he can bake one cookie per second.
He can also eat the cookies baked by himself. When there are cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes . Note that a cookie always needs to be baked for second, that is, he cannot bake a cookie in seconds when . When he choose to eat the cookies, he must eat all of them; he cannot choose to eat only part of them. It takes him seconds to eat the cookies regardless of how many, during which no cookies can be baked.
He wants to give cookies to Grandma. Find the shortest time needed to produce at least cookies not yet eaten.
Constraints
- is an integer.
Partial Score
- points will be awarded for passing the test set satisfying and .
- Additional points will be awarded for passing the test set without additional constraints.
Input
The input is given from Standard Input in the following format:
Output
Print the shortest time needed to produce at least cookies not yet eaten.
8 1
7
It is possible to produce cookies in seconds, as follows:
- After second: cookie is done.
- After seconds: more cookie is done, totaling . Now, Rng starts eating those cookies.
- After seconds: He finishes eating the cookies, and he can now bake cookies per second.
- After seconds: cookies are done.
- After seconds: more cookies are done, totaling .
- After seconds: more cookies are done, totaling .
- After seconds: more cookies are done, totaling .
1000000000000 1000000000000
1000000000000