F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Silly Keke

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 101    Accepted Submission(s): 4
Special Judge


Problem Description
Keke encountered another problem. The teacher gave her a part formed by the intersection of several prisms and asked her to find the volume of the part. But her brain doesn't work that she can't finish the work even in very simple cases. Therefore, she urgently needs your help.

To simplify the problem, the part is formed by the intersection of two infinitely long convex right prisms A and B. All joining edges of A are parallel to the $z$-axis, and all joining edges of B are parallel to the $x$-axis. If A and B do not intersect, Keke's teacher thinks that the part has a volume of 0.

Now Keke wants you to help her find the volume of the part.
 

Input
There are mutiple test cases, the number of which is no more than 10. For each test case:

The first line of input contains two integers $n$ and $m$ $(3\leq n, m\leq10^5)$, which represent the number of vertices of the base polygon of A and B respectively.

Following input $n$ lines, each line has $2$ real numbers, representing the vertex coordinates $(x, y) (-100\leq x, y\leq100)$ of the base polygon of A.

Following input $m$ lines, each line has $2$ real numbers, representing the vertex coordinates $(y, z) (-100\leq y, z\leq100)$ of the base polygon of B.

The input guarantees that the vertices of each polygon are given in clockwise or counterclockwise order. Numbers in the same line are separated by spaces. For more detailed input information, please see the sample.
 

Output
For each test case:

The first line of output should contain a non-negative real number, representing the volume of the part, accurate at least to 0.001.
 

Sample Input
4 3 10 0 0 10 -10 0 0 -10 5 0 -15 -10 -15 10
 

Sample Output
1041.666667
 

Hint

Windows gcc don't support long double yet, output with double instead.

 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 16:56:02, Gzip enabled