Innovative Washing Machine

시간 제한3초메모리 제한2048 MB

요약
물이 아래쪽에 면적 s로 고인 채 회전하는 볼록 다각형 드럼에서, 물속 꼭짓점들의 압력 불균형의 시간 평균을 구한다.
난이도

어려움10점 중 8점

유형
기하, 수학, 투 포인터
정답자
아직 제출이 없습니다

문제

You are asked to help a team that participates in "Innovation Workshop" --- an event where teams of students invent and prototype their innovative ideas. One of the teams developed a new innovative washing machine that significantly reduces the usage of energy needed for laundry.

The innovative idea was to use a convex polygon instead of a circle for the shape of a washing machine drum. You are given this polygon. A drum is rotating around some fixed point inside the polygon with a constant speed of 11 turn in 11 second.

Currently, the prototype is built and testing is started. There are ss litres of water in the drum. At each moment of time, water under the influence of gravity occupies a region with area ss at the bottom of the drum.

Vertices of the polygon that are underwater are under pressure. By Pascal's law, we know that pressure is proportional to depth. Let's define by d_1,d_2,…,d_kd\_1, d\_2, \ldots, d\_k depths of the vertices that are underwater at some moment of time, kk is the number of underwater vertices. Let's define the pressure imbalance as the average difference between underwater vertex depth and the maximum underwater vertex depth, i.e. 1k∑_i=1k(max⁡_j=1kd_j−d_i)\frac{1}{k} \sum\limits\_{i=1}^{k} \left(\max\limits\_{j=1}^{k} d\_j - d\_i \right). Note that the order of d_id\_i is not important.

The polygon from the third test case is rotated. Vertices 11, 22, 33, 44, 88 are underwater.

To select the optimal shape of the drum, the team wants to know the expected value of pressure imbalance for the moment of time selected uniformly from segment \[0,1]\[0, 1] (in seconds). Please help the team to calculate this value.

입력

The first line contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) --- the number of test cases. The next lines contain descriptions of test cases.

The first line contains two integers nn, ss (3≤n≤2⋅1053 \leq n \leq 2 \cdot 10^5, s≥1s \geq 1) --- the number of vertices in the polygon and the number of litres of water inside the drum. It is guaranteed that ss is less than the area of the polygon.

Each of the next nn lines contains two integers x_ix\_i, y_iy\_i (∣x_i∣,∣y_i∣≤108|x\_i|, |y\_i| \leq 10^8) --- coordinates of polygon vertices.

It is guaranteed that the given points form a convex polygon. The area of the polygon is positive and no two consecutive segments are collinear. The vertices of the polygon are given in counterclockwise order.

The sum of nn for all test cases does not exceed 2⋅1052 \cdot 10^5.

출력

For each test case, print a single real number --- the expected value of pressure imbalance for a random uniform moment of time.

Your answer will be accepted if its absolute or relative error does not exceed 10−510^{-5}; formally, if pp is your answer, and jj is the jury's answer, this should hold: ∣p−j∣max⁡1,∣j∣≤10−5\frac{|p - j|}{\max\\{1, |j|\\}} \le 10^{-5}.

예제1

  1. 예제 1

    입력
    4
    4 2
    0 0
    2 0
    2 2
    0 2
    3 1
    1 -1
    0 1
    -1 -1
    8 18
    -2 1
    -2 -3
    -1 -4
    0 -4
    3 -3
    4 -1
    4 0
    -1 2
    4 1
    99999998 99999999
    99999999 99999998
    100000000 99999999
    99999999 100000000
    
    예상 출력
    0.3729232286
    0.1379212354
    1.3663189952
    0.2636965438