链接:https://ac.nowcoder.com/acm/contest/57362/G
来源:牛客网
Given two segments that are perpendicular to each other on a two-dimension Cartesian plane, you need to pick a point uniformly at random on each of them and calculate the expected Euclidean distance between the two picked points.
输入格式
The input contains multiple cases. The first line of the input contains a single integer TTT (1≤T≤10001 \leq T \leq 1\,0001≤T≤1000), indicating the number of test cases.
For each case, each of the two lines contains four integers x1,y1,x2x_1,y_1,x_2x1,y1,x2 and y2y_2y2 (−1000≤x1,y1,x2,y2≤1000-1\,000 \le x_1, y_1, x_2, y_2 \le 1\,000−1000≤x1,y1,x2,y2≤1000), denoting a segment that connects (x1,y1)(x_1, y_1)(x1,y1) and (x2,y2)(x_2, y_2)(x2,y2). It is guaranteed that the two endpoints of each segment do not coincide, and that the two segments are perpendicular to each other.
输出格式
For each case, output a single real number, indicating the expected distance between the two randomly picked points.
Your answer is acceptable if its absolute or relative error does not exceed 10−910^{-9}10−9. Formally speaking, suppose that your output is aaa and the jury's answer is bbb, your output is accepted if and only if ∣a−b∣max(1,∣b∣)≤10−9\frac{|a - b|}{\max(1, |b|)} \leq 10^{-9}max(1,∣b∣)∣a−b∣≤10−9.