CF1426A.Floor Number

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is nn .

There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 22 apartments, every other floor contains xx apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers 11 and 22 , apartments on the second floor have numbers from 33 to (x+2)(x + 2) , apartments on the third floor have numbers from (x+3)(x + 3) to (2x+2)(2 \cdot x + 2) , and so on.

Your task is to find the number of floor on which Petya lives. Assume that the house is always high enough to fit at least nn apartments.

You have to answer tt independent test cases.

输入格式

The first line of the input contains one integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then tt test cases follow.

The only line of the test case contains two integers nn and xx ( 1n,x10001 \le n, x \le 1000 ) — the number of Petya's apartment and the number of apartments on each floor of the house except the first one (there are two apartments on the first floor).

输出格式

For each test case, print the answer: the number of floor on which Petya lives.

输入输出样例

  • 输入#1

    4
    7 3
    1 5
    22 5
    987 13

    输出#1

    3
    1
    5
    77

说明/提示

Consider the first test case of the example: the first floor contains apartments with numbers 11 and 22 , the second one contains apartments with numbers 33 , 44 and 55 , the third one contains apartments with numbers 66 , 77 and 88 . Therefore, Petya lives on the third floor.

In the second test case of the example, Petya lives in the apartment 11 which is on the first floor.

首页