CF1426A.Floor Number
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is n.
There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 2 apartments, every other floor contains x apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers 1 and 2, apartments on the second floor have numbers from 3 to (x+2), apartments on the third floor have numbers from (x+3) to (2⋅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 n apartments.
You have to answer t independent test cases.
瓦西娅去拜访他的同学佩佳。瓦西娅知道佩佳的公寓号是 n。
佩佳所住的楼房只有一个入口,公寓分布规则如下:第一层有 2 套公寓,其余每一层均有 x 套公寓。公寓编号从 1 开始,按楼层自下而上顺序编号:即第一层的公寓编号为 1 和 2;第二层的公寓编号为 3 至 (x+2);第三层的公寓编号为 (x+3) 至 (2⋅x+2);依此类推。
你的任务是找出佩佳所住的楼层号。假设该楼房足够高,总公寓数至少为 n。
你需要回答 t 个相互独立的测试用例。
输入格式
The first line of the input contains one integer t (1≤t≤1000) — the number of test cases. Then t test cases follow.
The only line of the test case contains two integers n and x (1≤n,x≤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).
输入的第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。接下来是 t 个测试用例。
每个测试用例仅一行,包含两个整数 n 和 x(1≤n,x≤1000),分别表示 Petya 所在公寓的编号,以及除第一层外每层楼的公寓数量(第一层有 2 套公寓)。
输出格式
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 1 and 2, the second one contains apartments with numbers 3, 4 and 5, the third one contains apartments with numbers 6, 7 and 8. Therefore, Petya lives on the third floor.
In the second test case of the example, Petya lives in the apartment 1 which is on the first floor.
考虑示例中的第一个测试用例:第一层楼包含编号为 1 和 2 的公寓,第二层楼包含编号为 3、4 和 5 的公寓,第三层楼包含编号为 6、7 和 8 的公寓。因此,Petya 住在第三层楼。
在示例的第二个测试用例中,Petya 住在编号为 1 的公寓,该公寓位于第一层楼。
输入解题思路,AI测评打分。不知道怎么写?