欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2166B.Tab Closing
Tab Closing
You've been staring at your computer screen for too long; it is time to give it a break and go touch some grass.
Your screen is a line of length , and there are tabs displayed on it. You want to close all of the tabs by clicking on the x's at their right endpoint.
Every tab is a segment of length , where is the number of remaining tabs. The tabs are always tightly arranged in sequence from the left endpoint of the screen; that is, the x's will be at $\textrm{len},2\cdot \textrm{len},3\cdot \textrm{len},\ldots,m\cdot\textrm{len}$ units away from the left endpoint. Please note that the length of each tab will change as you are closing tabs.
Now your cursor is at the left endpoint of the screen. You wonder what the minimum number of times you need to move the mouse to close all tabs is.
If you have difficulty understanding the statement, you may also refer to your browser tab for a visualization, or click here.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
Each test case is a line of three integers , , and (, ).
Output
For each test case, output a single integer — the minimum number of times you need to move the mouse to close all tabs.
Note
In the first test case, a possible course of action is to move your cursor to and press times.
In the second test case, a possible course of action is to move your cursor to and press once, then move it to and press again. It can be proved that the tabs cannot be closed with less than moves.
Samples
12
8 1 6
9 6 2
10 3 1
10 1 10
9 2 1
5 5 6
6 2 7
9 1 9
3 2 6
8 1 7
8 1 9
8 2 4
1
2
1
1
1
1
2
1
2
1
2
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |