#C8486. Minimum Actions to Place Boxes

    ID: 52473 Type: Default 1000ms 256MiB

Minimum Actions to Place Boxes

Minimum Actions to Place Boxes

You are given a series of test cases. In each test case, you have to determine the minimum number of actions required to place all the given boxes in a line. In one action, you can place up to K boxes. If K is greater than 0, you can place boxes in groups (i.e. the answer is (\lceil \frac{M}{K} \rceil)). If K equals 0, then you have to place each box individually. This problem requires careful handling of integer division and edge cases.

inputFormat

The input is read from standard input (stdin).

The first line contains an integer T, the number of test cases. Each of the following T lines contains two space-separated integers M and K, where M is the total number of boxes and K is the maximum number of boxes that can be placed in one action (if K is 0, each box must be placed individually).

outputFormat

For each test case, output a single integer on a new line — the minimum number of actions required to place all the boxes.## sample

3
10 3
7 2
5 5
4

4 1

</p>