A13809 | Floor Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 \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 $n$ apartments.
You have to answer $t$ independent test cases.
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 \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 $n$ apartments.
You have to answer $t$ independent test cases.
输入格式
The first line of the input contains one integer $t$ ( $1 \le t \le 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 \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).
The only line of the test case contains two integers $n$ and $x$ ( $1 \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 $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.
In the second test case of the example, Petya lives in the apartment $1$ which is on the first floor.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted