欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1282A.Temporarily unavailable
Temporarily unavailable
Polycarp lives on the coordinate axis and travels from the point to . It moves uniformly rectilinearly at a speed of one unit of distance per minute.
On the axis at the point the base station of the mobile operator is placed. It is known that the radius of its coverage is . Thus, if Polycarp is at a distance less than or equal to from the point , then he is in the network coverage area, otherwise — no. The base station can be located both on the route of Polycarp and outside it.
Print the time in minutes during which Polycarp will not be in the coverage area of the network, with a rectilinear uniform movement from to . His speed — one unit of distance per minute.
Input
The first line contains a positive integer () — the number of test cases. In the following lines are written test cases.
The description of each test case is one line, which contains four integers , , and (, ) — the coordinates of the starting and ending points of the path, the base station, and its coverage radius, respectively.
Any of the numbers , and can be equal (either any pair or all three numbers). The base station can be located both on the route of Polycarp and outside it.
Output
Print numbers — answers to given test cases in the order they are written in the test. Each answer is an integer — the number of minutes during which Polycarp will be unavailable during his movement.
Note
The following picture illustrates the first test case.
Polycarp goes from to . The yellow area shows the coverage area of the station with a radius of coverage of , which is located at the point of . The green area shows a part of the path when Polycarp is out of coverage area.
Samples
9
1 10 7 1
3 3 3 0
8 2 10 4
8 2 10 100
-10 20 -17 2
-3 2 2 0
-3 1 2 0
2 3 2 3
-1 3 -2 2
7
0
4
0
30
5
4
0
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |