问题 G: Expected Distance

内存限制:512 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:2 通过:2

题目描述

链接: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\,0001T1000), 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\,0001000x1,y1,x2,y21000), 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}109. 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)ab109.

输入样例 复制

1
0 0 1 0
0 0 0 1

输出样例 复制

0.765195716464212691

数据范围与提示

In the sample case, the expected distance is