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