欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1066A.Vova and Train
Vova and Train
Vova plans to go to the conference by train. Initially, the train is at the point and the destination point of the path is the point . The speed of the train is length unit per minute (i.e. at the first minute the train is at the point , at the second minute — at the point and so on).
There are lanterns on the path. They are placed at the points with coordinates divisible by (i.e. the first lantern is at the point , the second is at the point and so on).
There is also exactly one standing train which occupies all the points from to inclusive.
Vova can see the lantern at the point if is divisible by and there is no standing train at this position (). Thus, if the point with the lantern is one of the points covered by the standing train, Vova can't see this lantern.
Your problem is to say the number of lanterns Vova will see during the path. Vova plans to go to different conferences, so you should answer independent queries.
Input
The first line of the input contains one integer () — the number of queries.
Then lines follow. The -th line contains four integers (, ) — destination point of the -th path, the period of the lantern appearance and the segment occupied by the standing train.
Output
Print lines. The -th line should contain one integer — the answer for the -th query.
Note
For the first example query, the answer is . There are lanterns at positions , , , and , but Vova didn't see the lanterns at positions and because of the standing train.
For the second example query, the answer is because the only lantern is at the point and there is also a standing train at this point.
For the third example query, the answer is because there are lanterns, but Vova didn't see the lanterns from the position to the position inclusive.
For the fourth example query, the answer is because the standing train covers the whole path.
Samples
4
10 2 3 7
100 51 51 51
1234 1 100 199
1000000000 1 1 1000000000
3
0
1134
0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |