Catch the Rain

Time Limit
1s
Memory Limit
32768KB
Judge Program
Standard
Ratio(Solve/Submit)
50.00%(6/12)
Description:

It's raining!
Members of the acm team came up with a whimsy and decided to start a rain catching competition.
Everyone has two same wooden boards to catch the rain.
The wooden boards in everyone's hands have been placed. Now you need to help calculate how much rain can each one collect?

To simplify the problem, it's converted into a plane problem. Wooden boards are regarded as line segments, and the rainfall is the area.

Example 1 explained in Figure 1:

Input:

The first line contains the number of test cases t(t<=100).
Each test case consists of 8 integers x1, y1, x2, y2, x3, y3, x4, y4 ,whose absolute value not exceed 10,000.
(x1, y1), (x2, y2) are the endpoints of one board, and (x3, y3), (x4, y4) are the endpoints of the other one.

Output:

For each test case output a single line containing a real number with precision up to two decimal places - the amount of rain collected.

Sample Input:
2
0 1 1 0
1 0 2 1
0 1 2 1
1 0 1 2
Sample Output:
1.00
0.00

Submit