No.2416 vs Slime
タグ : / 解いたユーザー数 202
作問者 :
LaFolia13
hikikomori
sepa38
Seed57_cash
Problem Statement
You are about to fight a slime.
When you attack a slime with health $h$, the attacked slime disappears, and $2$ new slimes with health $\displaystyle \left \lfloor \frac{h}{A} \right \rfloor$ are created.
You win if the health of all slimes, including the created ones, becomes $0$ or less.
Find the minimum number of attacks required to win against $1$ slime with health $H$.
Here, $\displaystyle \lfloor x \rfloor$ denotes the largest integer not exceeding $x$.
Constraints
- $1 \leq H \leq 10^{12}$
- $2 \leq A \leq 10^{12}$
- All inputs are integers.
Input
The input is given from standard input in the following format.
$H$ $A$
Output
Output the answer to the problem on one line.
Sample
Sample 1
Input
3 2
Output
3
Initially, there is $1$ slime with health $3$.
Attacking the slime with health $3$ creates $2$ slimes with health $\displaystyle \left \lfloor \frac{3}{2} \right \rfloor = 1$.
Attacking a slime with health $1$ creates $2$ slimes with health $0$, but since these slimes have health $0$ or less, no additional attacks on the created slimes are needed.
Since $2$ slimes with health $1$ were created, the health of all slimes can be made $0$ or less with a total of $3$ attacks.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。