时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld
题目描述
This problem is a variant of the General’s Horse Drinking Water problem.
Given that the general’s horse is at point

, the tent is at point

,
and the river is located along the positive half of the x-axis and the
positive half of the y-axis, find the shortest distance the horse needs
to travel to drink water from the river and return to the tent.
输入描述:
Each test contains multiple test cases. The first line contains the number of test cases

(

). The description of the test cases follows.
Each test case consists of a single line containing four integers

(

), describing the positions of the general’s horse and the tent.
输出描述:
For each test case, output a decimal number representing the shortest distance the horse needs to travel to drink water from the river and return to the tent.
Your answer is considered correct if its absolute or relative error does not exceed

.
Formally, let your answer be

, and the jury’s answer be

. Your answer is accepted if and only if

.
示例1
输入
复制
5
1 3 3 3
1 1 1 1
1 5 4 2
11 4 5 14
19 1 9 810
输出
复制
4
2
5.8309518948
18.8679622641
809.4844038028
备注:
In test case 3, the optimal path is: