#K69497. Minimum Sprinklers Needed

    ID: 33099 Type: Default 1000ms 256MiB

Minimum Sprinklers Needed

Minimum Sprinklers Needed

You are given a line of N plants. A sprinkler can cover a range of 2R+1 consecutive plants, where R is the reach of the sprinkler. Your task is to determine the minimum number of sprinklers required to water all the plants.

If R = 0, then each plant must be watered individually, i.e. you will need N sprinklers.

The answer for each test case is computed using the formula:

\[ \text{sprinkler_range} = 2R + 1, \quad \text{sprinklers_needed} = \left\lceil \frac{N}{2R+1} \right\rceil \]

inputFormat

The first line of input contains an integer T representing the number of test cases.

Each of the next T lines contains two space-separated integers: N (the number of plants) and R (the reach of each sprinkler).

outputFormat

For each test case, print a single integer on a new line representing the minimum number of sprinklers needed.

## sample
2
5 1
6 2
2

2

</p>