QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3737. Triangles and Rectangles

統計

Bobo has a triangle and a rectangle, and he wants to find the area of their intersection.

Specifically, the triangle and the rectangle are described by $8$ integers $x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4$. The vertices of the triangle are $(x_1, y_1), (x_1, y_2), (x_2, y_1)$. The vertices of the rectangle are $(x_3, y_3), (x_3, y_4), (x_4, y_4), (x_4, y_3)$.

Input

The input contains no more than $30000$ test cases.

Each test case consists of two lines. The first line contains $4$ integers $x_1, y_1, x_2, y_2$ ($x_1 \neq x_2, y_1 \neq y_2$).

The second line contains $4$ integers $x_3, y_3, x_4, y_4$ ($x_3 < x_4, y_3 < y_4$).

($0 \leq x_i, y_i \leq 10^4$)

Output

For each test case, output a real number representing the area of the intersection. An absolute or relative error of less than $10^{-6}$ is considered correct.

Examples

Input 1

1 1 3 3
0 0 2 2
0 3 3 1
0 0 2 2
4462 1420 2060 2969
4159 257 8787 2970

Output 1

1.00000000
0.75000000
439744.13967527

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.