Stillwater Prison
时间限制:C/C++/Rust/Pascal 6秒,其他语言12秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld

题目描述

In the problem H of BCPC 2020 Final, Mocha had used most of her magic to protect Arad mainland. After that, Mocha tried to go back to her own world by travel magic. However, Mocha spent so much magic to protect Arad mainland that she can’t maintain mana stability during travel. As a result, Mocha found she woubld be transported into the Stillwater Prison!

The magic is forbidden in the Stillwater Prison, so Mocha wants to escape the Stillwater Prison as soon as possible. The Stillwater Prison can be regard as a convex polygon in an infinite two-dimensional plane. Mocha will be transported to some point P which is strictly inside the polygon. Mocha will choose one point Q which is on the edge of the polygon (Q can also be some vertice of the polygon), then she will move from point P to point Q along the segment PQ.

Mocha is too anxious to calm down and calculate. Please help her to calculate the minimum distance she needs to move to escape the Stillwater Prison. Since Mocha can’t confirm where she will be transported, you need to answer multiple queries.

输入描述:

The first line contains one integer n (3\leq n\leq 10^5), indicating the number of vertices of the convex polygon.

In the next n lines, each line contains two integers x,y (-10^9\leq x,y\leq 10^9), indicating the coordinates of the vertices of the convex polygon. The coordinates of the vertices are given in counterclockwise order.

The next line contains one integer q (1\leq q\leq 10^5), indicating the number of queries.

In the next q lines, each line contains two integers P_x,P_y (-10^9\leq P_x,P_y\leq 10^9), indicating the coordinate of the point P where Mocha will be transported to. It’s guaranteed that P is strictly inside the polygon.

输出描述:

For each query, print a real number in a single line, indicating the minimum distance she needs to move to escape the Stillwater Prison. Your answer will be considered correct if its relative or absolute error does not exceed 10^{-6}.

示例1

输入

复制
3
-10 -10
1000 2
0 11515
3
1 1
250 500
700 600

输出

复制
10.8685398419
259.5573860250
247.1282543552
示例2

输入

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

输出

复制
2.0000000000
1.0000000000
1.0000000000
1.0000000000
1.0000000000
示例3

输入

复制
4
0 0
7 0
5 5
-1 4
3
2 1
4 3
1 3

输出

复制
1.0000000000
1.6712580436
1.3151918984