Illuminations II
题号:NC233145
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

You are given two convex polygons, where the larger polygon has n vertices and the smaller polygon has m vertices. All the vertices of the smaller polygon locate strictly inside the larger polygon, thus the smaller polygon fully locates strictly inside the larger polygon.


Our dear friend JB is going to install an illuminant on the interior boundaries of the larger polygon to light up some exterior boundaries of the smaller polygon. Feeling indecisive, JB decides to choose where to install the illuminant uniformly at random on the interior boundaries of the larger polygon, and you need to calculate the expected length of the illuminated boundaries of the smaller polygon.

输入描述:

The first line contains two integers n and m .

The following n lines describe the vertices on the larger convex polygon, each of which contains two integers x and y , indicating the coordinates of a vertex on the polygon. All these n vertices are given in counter-clockwise order and any three of them are not collinear.

Then the following m lines describe the vertices on the smaller convex polygon, each of which contains two integers x and y , indicating the coordinates of a vertex on the polygon. All these m vertices are also given in counter-clockwise order and any three of them are not collinear.

It is guaranteed that all the vertices of the smaller polygon locate strictly inside the larger polygon.

输出描述:

Output the expected length of the illuminated boundaries of the smaller polygon when JB chooses where to install the illuminant uniformly at random on the interior boundaries of the larger polygon.

Your answer is acceptable if its absolute or relative error does not exceed . Formally speaking, suppose that your output is x and the jury's answer is y, your output is accepted if and only if .

示例1

输入

复制
4 4
0 0
3 0
3 3
0 3
1 1
2 1
2 2
1 2

输出

复制
1.666666666666667

说明

For the sample case, it can be shown that the length of the illuminated boundaries of the smaller polygon is 1 with probability \frac{1}{3} and 2 with probability \frac{2}{3}, thus the expected length is 1×\frac{1}{3}+2×\frac{2}{3}=\frac{5}{3}.