题目描述
Problem Description
Ringo is baking cookies.
Initially, Ringo can bake 1 cookie per second.
Ringo can eat cookies. When there are a total of \( x \) uneaten cookies, Ringo can eat all of them to increase the number of cookies he can bake per second to exactly \( x \). Cookies cannot be eaten partially; when eaten, all must be consumed. Eating cookies takes \( A \) seconds regardless of the number of cookies, during which no cookies can be baked. Also, cookies are baked simultaneously every second, so it's not possible to bake, for example, \( x/2 \) cookies in 0.5 seconds.
Ringo wants to prepare \( N \) cookies to give to his grandmother. Find the minimum time required for Ringo to have at least \( N \) uneaten cookies.
Input Format
The input is given from the standard input in the following format:
\( N \) \( A \)
Output Format
Output the minimum time required for Ringo to have at least \( N \) uneaten cookies.
Sample Input and Output
Sample Input #1
8 1
Sample Output #1
7
Sample Input #2
1000000000000 1000000000000
Sample Output #2
1000000000000
Sample Input #3
123456 7
Sample Output #3
78
Notes/Hints
Constraints
- \( 1 \leq N \leq 10^{12} \)
- \( 0 \leq A \leq 10^{12} \)
- \( A \) is an integer.
Partial Points
- If you solve the dataset where \( N \leq 10^6 \) and \( A \leq 10^6 \), you will be awarded 500 points.
- If you solve the dataset without additional constraints, you will be awarded an additional 500 points.
Sample Explanation 1
By acting as follows, it is possible to prepare 8 cookies in 7 seconds:
- After 1 second: 1 cookie is baked.
- After 2 seconds: 1 more cookie is baked, totaling 2 cookies. Here, all 2 cookies are eaten.
- After 3 seconds: Cookies are done being eaten, and Ringo can now bake 2 cookies per second.
- After 4 seconds: 2 cookies are baked.
- After 5 seconds: 2 more cookies are baked, totaling 4 cookies.
- After 6 seconds: 2 more cookies are baked, totaling 6 cookies.
- After 7 seconds: 2 more cookies are baked, totaling 8 cookies.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分