欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2007A.Dora's Set
Dora's Set
Dora has a set containing integers. In the beginning, she will put all integers in into the set . That is, an integer is initially contained in the set if and only if . Then she allows you to perform the following operations:
- Select three distinct integers , , and from the set , such that .
- Then, remove these three integers from the set .
What is the maximum number of operations you can perform?
Recall that means the greatest common divisor of integers and .
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers and () — the range of integers in the initial set.
Output
For each test case, output a single integer — the maximum number of operations you can perform.
Note
In the first test case, you can choose , , in the only operation, since , and then there are no more integers in the set, so no more operations can be performed.
In the second test case, you can choose , , in the only operation.
In the third test case, you can choose , , in the first operation, , , in the second operation, and , , in the third operation. After the three operations, the set contains the following integers: , , . It can be proven that it's impossible to perform more than operations.
Samples
8
1 3
3 7
10 21
2 8
51 60
2 15
10 26
1 1000
1
1
3
1
2
3
4
250
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |