CF1282A.Temporarily unavailable

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp lives on the coordinate axis OxOx and travels from the point x=ax=a to x=bx=b. It moves uniformly rectilinearly at a speed of one unit of distance per minute.

On the axis OxOx at the point x=cx=c the base station of the mobile operator is placed. It is known that the radius of its coverage is rr. Thus, if Polycarp is at a distance less than or equal to rr from the point x=cx=c, 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 x=ax=a to x=bx=b. His speed — one unit of distance per minute.

Polycarp 生活在坐标轴 OxOx 上,从点 x=ax=a 出发,沿直线匀速运动至点 x=bx=b,速度为每分钟 1 个单位距离。

在坐标轴 OxOx 上的点 x=cx=c 处设有一家移动运营商的基站。已知该基站的覆盖半径为 rr。因此,当 Polycarp 到点 x=cx=c 的距离小于或等于 rr 时,他处于网络覆盖范围内;否则,他不在覆盖范围内。该基站既可能位于 Polycarp 的行进路线上,也可能位于路线之外。

请输出 Polycarp 从 x=ax=a 匀速直线运动至 x=bx=b 过程中,未处于网络覆盖范围内的时间(单位:分钟)。他的速度为每分钟 1 个单位距离。

输入格式

The first line contains a positive integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases. In the following lines are written tt test cases.

The description of each test case is one line, which contains four integers aa, bb, cc and rr (−108≤a,b,c≤108-10^8 \le a,b,c \le 10^8, 0≤r≤1080 \le r \le 10^8) — the coordinates of the starting and ending points of the path, the base station, and its coverage radius, respectively.

Any of the numbers aa, bb and cc 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.

第一行包含一个正整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。接下来的行中包含 tt 个测试用例。

每个测试用例的描述为一行,包含四个整数 aa、bb、cc 和 rr(−108≤a,b,c≤108-10^8 \le a,b,c \le 10^8,0≤r≤1080 \le r \le 10^8),分别表示路径起点与终点的坐标、基站位置坐标及其覆盖半径。

aa、bb、cc 中任意两个或全部三个数均可相等。基站可能位于 Polycarp 的行进路线上,也可能在其路线之外。

输出格式

Print tt 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.

输出 tt 个数字——即按测试用例在输入中出现的顺序给出的答案。每个答案均为一个整数,表示 Polycarp 在移动过程中无法被联系上的分钟数。

输入输出样例

  • 输入#1

    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

    输出#1

    7
    0
    4
    0
    30
    5
    4
    0
    3

说明/提示

The following picture illustrates the first test case.

Polycarp goes from 11 to 1010. The yellow area shows the coverage area of the station with a radius of coverage of 11, which is located at the point of 77. The green area shows a part of the path when Polycarp is out of coverage area.

下图展示了第一个测试用例。


Polycarp 从 11 走到 1010。黄色区域表示位于点 77、覆盖半径为 11 的基站的覆盖范围。绿色区域表示 Polycarp 行走路径中处于覆盖范围之外的部分。

输入解题思路,AI测评打分。不知道怎么写?

首页