問題一覧 > 通常問題

No.2416 vs Slime

レベル : / AI推定難易度 : 214 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 202
作問者 : dyktr_06 / テスター : Nafmo2 LaFolia13 hikikomori sepa38 Seed57_cash Udon ryota2357
お気に入りにしたユーザー ProblemId : 9702 / 自分の提出
問題文最終更新日: 2023-08-12 14:23:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 016 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。