欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1945B.Fireworks
Fireworks
One of the days of the hike coincided with a holiday, so in the evening at the camp, it was decided to arrange a festive fireworks display. For this purpose, the organizers of the hike bought two installations for launching fireworks and a huge number of shells for launching.
Both installations are turned on simultaneously. The first installation launches fireworks every minutes (i.e., after minutes after launch). The second installation launches fireworks every minutes (i.e., after minutes after launch).
Each firework is visible in the sky for minutes after launch, i.e., if a firework was launched after minutes after the installations were turned on, it will be visible every minute from to , inclusive. If one firework was launched minutes after another, both fireworks will be visible for one minute.
What is the maximum number of fireworks that could be seen in the sky at the same time?
Input
Each test consists of several test cases. The first line contains a single integer () — the number of test cases. Then follow the descriptions of the test cases.
The first and only line of each test case contains integers , , () — the frequency of launching for the first installation, the second installation, and the time the firework is visible in the sky.
Output
For each set of input data, output a single number — the maximum number of fireworks that can be seen simultaneously.
Note
In the first set of input data, the fireworks are visible in the sky for minutes. Since the first installation launches fireworks every minutes, and the second one every minutes, two fireworks launched from the same installation will not be visible in the sky at the same time. At the same time, after minutes from the start of the holiday, one firework from the first and one from the second camp will be visible. Thus, it is possible to see no more than fireworks simultaneously.
In the third set of input data, fireworks will be visible after minutes:
- fireworks launched from the first installation at times [];
- fireworks launched from the second installation at times [].
Samples
6
6 7 4
3 4 10
7 8 56
5 6 78123459896
1 1 1
1 1 1000000000000000000
2
7
17
28645268630
4
2000000000000000002
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |