#K49622. Minimum Number of Jumps
Minimum Number of Jumps
Minimum Number of Jumps
You are given two positive integers n and k, where n represents the target stone index and k is the maximum distance that can be jumped in a single move. The stones are numbered from 0 to n, and you start at stone 0. Your task is to determine the minimum number of jumps required to reach stone n from stone 0. If n is 0, you are already at the target and the answer is 0.
The jump count is determined by the minimal number of moves required under the constraint that in each move you may jump at most k units. Formally, if you denote the number of jumps by J, then you are trying to achieve:
provided that k > 0
and n >= 0
. Note that if k >= n
and n > 0
, you can reach the target with just one jump.
It is guaranteed that the inputs will be such that a solution exists under these assumptions.
inputFormat
The input consists of two space-separated integers read from stdin:
n
— the index of the target stone (0 ≤ n ≤ 10^9)k
— the maximum jump distance (1 ≤ k ≤ 10^9)
You can assume that k
is always a positive integer.
outputFormat
Output a single integer to stdout which is the minimum number of jumps needed to reach stone n from stone 0.
## sample5 2
3
</p>