問題一覧 > 通常問題

No.415 Pyon

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 317
作問者 : ei1333333 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 1224 / 自分の提出
問題文最終更新日: 2026-06-25 22:10:10
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 147 (順位表) の他の問題:

Problem Statement

$N$ platforms are arranged on a circular ring at equal intervals of distance $1$. Starting from a certain platform, the platforms are numbered from $1$ to $N$ in order.

Usagi-chan suddenly felt like going "pyon" (hopping).

Currently, Usagi-chan is on platform $1$. With $1$ pyon, Usagi-chan can glide along the ring and move only to a platform at distance $D$ away.

Usagi-chan can repeat pyon any number of times, but the platforms are delicate, so once Usagi-chan does a pyon, the platform Usagi-chan was originally on disappears.

Find the maximum number of times Usagi-chan can pyon.

Input

$N$ $D$

The number of platforms $N(1 \le N \le 2 \times 10^9)$ and the pyon distance $D(1 \le D \le N)$ are given on $1$ line.

Output

Output the maximum number of times Usagi-chan can pyon on $1$ line.

Print a newline at the end.

Sample

Sample 1
Input
4 2
Output
1

It is only possible to move from platform $1$ to platform $3$.

Sample 2
Input
5 2
Output
4

For example, Usagi-chan moves as follows.

  • Platform $1$ -> Platform $3$ -> Platform $5$ -> Platform $2$ -> Platform $4$

Sample 3
Input
114 114
Output
0

Note that there are cases where Usagi-chan cannot move even once.

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