問題一覧 > 通常問題

No.63 Pocky Game

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 1245
作問者 : yoza
お気に入りにしたユーザー ProblemId : 134 / 自分の提出
問題文最終更新日: 2026-06-25 16:37:07
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 51 (順位表) の他の問題:

Problem Statement

Haruka and Yu are very close friends, so the two of them decided to play the Pocky game.

The two of them bite a Pocky stick of length \(L\mathrm{(mm)}\) from its two ends, each moving toward the center.
Each time, both of them bite off \(K\mathrm{(mm)}\) of the Pocky at the same moment.
Yu is shy, so
as soon as she realizes that their lips would touch if both of them bit the Pocky at the next moment, she stops biting,
and Haruka eats all of the rest.

In this case, how many \(\mathrm{mm}\) of the Pocky does Yu eat?

Input

L K

  • The inputs \(L, K\) are each given as integer values.
  • \(1 \leq L \leq 10^{9}\) represents the length of the Pocky used in the game.
  • \(1 \leq K \leq 50\) represents the length of the Pocky each of them bites off at a time.
  • Their lips are considered to touch when the remaining length of the Pocky is 0 (or less).

Output

Calculate and output the length of the Pocky that Yu eats.

Sample

Sample 1
Input
90 20
Output
40

If each of them tried to take a 3rd bite, their lips would touch, so Yu eats \(40\mathrm{(mm)}\).

Sample 2
Input
100 50
Output
0

Yu may not take even a single bite.

Sample 3
Input
1111 11
Output
550

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