409232: GYM103463 L Line problem
Description
We have learned your team is good at geometry problems. So we ask you a simple problem.
Now you have two segments in a $$$2$$$-dimensional plane, you should tell us the length of the intersection of two line segments.
What you need to pay attention to is, if these two line segments intersect at one point, we consider their intersecting length to be $$$0$$$.
InputThere are several test cases.
The first line contains a single integer $$$T(1 \leq T \leq 10^3)$$$, denoting the number of test cases. Then follow all the test cases.
The first line contains four integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, $$$y_2$$$$$$(-10^{9} \leq x_1, y_1, x_2, y_2 \leq 10^{9})$$$, representing the two points of the first line segment.
The second line contains four integers $$$x_3$$$, $$$y_3$$$, $$$x_4$$$, $$$y_4$$$$$$(-10^{9} \leq x_3, y_3, x_4, y_4 \leq 10^{9})$$$, representing the two points of the second line segment.
OutputFor each test case, print the length of the intersection of two line line segments.
Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-9}$$$.
Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-9}$$$.
ExampleInput2 0 0 3 3 1 1 2 2 0 0 1 1 1 1 2 2Output
1.41421356237309514547 0.00000000000000000000