407543: GYM102823 L Two Ants

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Two Antstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

There are two ants landing on an infinite ground containing two chocolate sticks, one white and one black. However, they do not know the accurate position of each other.

"Where are you?", Ant A shouted.

"I don't know. But from my own view I can see the white stick only!", Ant B replies.

"Well I cannot get your accurate position but I know where you may be!", Ant A says.

If two sticks can be regarded as segments which exclude the endpoints and share no more than one common point, can you guess where Ant B may be? Print the total area of that instead.

Input

The first line of input file contains only one integer $$$T$$$ ($$$1\le T \le 1000$$$) indicating the number of test cases.

Then there are $$$T$$$ lines followed, with one test case each line.

For each test case, there are eight integers $$$x_w, y_w, X_w, Y_w, x_b, y_b, X_b, Y_b$$$ ranging in $$$[-1000,1000]$$$. The white one is represented by its two endpoints' positions $$$(x_w, y_w), (X_w, Y_w)$$$ and the black one is represented by its two endpoints' positions $$$(x_b, y_b), (X_b, Y_b)$$$.

Output

Print $$$T$$$ lines exactly.

For each line, please output Case $$$d$$$: ($$$d$$$ represents the order of test case) first and then the answer, whose absolute error should be less than $$$10^{-6}$$$ . If that area is infinite, print inf as answer instead.

ExampleInput
3
0 0 0 1 0 0 1 0
0 0 1 0 0 1 0 -1
1 1 1 2 0 0 0 3
Output
Case 1: inf
Case 2: 0.000
Case 3: 0.2500000000
Note

Sample 3:

Only the area $$$S$$$ meets the requirement and its total area is $$$0.25$$$.

加入题单

上一题 下一题 算法标签: