問題一覧 > 通常問題

No.477 MVP

レベル : / AI推定難易度 : 625 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 128 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 451
作問者 : LayCurse / テスター : mai
お気に入りにしたユーザー ProblemId : 1186 / 自分の提出
問題文最終更新日: 2026-06-27 07:26:24
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
yukicoder contest 155 (順位表) の他の問題:

Problem Statement

This is a story about a certain RPG.
The enemy has $N$ HP. At first, you fight it as $1$ person, but if you request reinforcements, other online players come to help and multiple players can fight together.
In that case, the $K$ players who dealt the most damage become MVPs and obtain a special item.
In case of a tie (when the $K$-th player and the $K+1$-th player have dealt the same amount of damage), the MVPs are chosen at random.
Now, find the minimum amount of damage you should deal before requesting reinforcements in order to surely become an MVP.
Many of the other online players are strong, so after you request reinforcements, the enemy may be defeated before you deal any damage.
Also, if the number of players who dealt $1$ or more damage is less than $K$, all players who dealt damage become MVPs.

Input

$N$ $K$

$1 \leq N \leq 10^{18}$
$1 \leq K \leq 10^{18}$

Output

Output the answer.

Sample

Sample 1
Input
15 1
Output
8

The enemy has $15$ HP. If you deal $8$ damage and then request reinforcements, even if a player who comes to help deals $7$ damage, you will be the player who dealt the most damage.

Sample 2
Input
1000000000000000000 2
Output
333333333333333334

For example, even if 2 players come to help and deal $500000000000000000$ and $166666666666666666$ damage, you become an MVP as the player who dealt the $2$-nd most damage.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。