172. TOPC 2017 PE. Fences

0 Judge

Code: 0


Fences

註:此題為 special judge,目前 Sky OJ 尚未支援此功能,想測這題的可以先去找 Chuck。

英文題目敘述

Your friend, Donald, has a villa surrounded by two tiers of fences, and he wants to calculate the area of land between them. He can measure the length of any fence, but Donald has no idea on calculating the area. Watson, one of Donald's friends, notices that the fences are probably built by a computer scientist mastering the knowledge of computational geometry, because the following facts are no coincidence.

  • The shape of the land inside the outer tier is a perfect circle $C$. Let $B$ denote the set of points on the boundary of $C$.
  • The shape of the land inside the inner tier is a non-self-intersecting polygon $P$ of $n$ vertices. I.e., two edges do not intersect if they don't share a common vertex. Let $V$ denote the set of vertices of $P$.
  • All vertices of $P$ have identical minimum distances to $C$. In other words, for distinct vertices $(x_u,y_u),(x_v,y_v)\in V$, we have $$\min_{(x,y)\in B}\sqrt{(x-x_u)^2+(y-y_u)^2}=\min_{(x,y)\in B}\sqrt{(x-x_v)^2+(y-y_v)^2}.$$

Suddenly, you know how to calculate the area of land between the two tiers of fences from the total length $c$ of outer tier and the lengths $\ell_1,\dots,\ell_n$ of the $n$ edges of $P$. Note that Donald can measure these length. Could you help him to calculate the area?

英文輸入說明

The first line of the input contains a positive integer $T$ indicating the number of test cases. Each test case consists of two lines. The first line contains two numbers $c$ and $n$ separated by a space. $c$ is the total length of the outer tier, i.e., $c$ is the perimeter of $C$. $n$ is the number of vertices of P. The second line contains $n$ positive integers $\ell_1,\dots,\ell_n$ indicating the lengths of edges of $P$.

You may assume:

  • $1 \le T \le 100$
  • $3 \le n \le 10$
  • $10 \le c\le 1000$
  • $\ell_1,\dots,\ell_n>0$
  • $P$ must be inside the circle $C$.

英文輸出說明

For each case, output the area between the two tiers of fences. Your answer will be accepted if the absolute error or the relative error is less than $10^{-6}$.

範例輸入

2
10.0 3
1 1 1
10.0 4
1 1 1 1

範例輸出

7.524734452702549
6.9577471545947684

中文題目敘述

你的朋友東納德的別墅外有兩層圍籬,他想要計算在這兩層圍籬之間的土地面積。他能測量圍籬的長度,但他對計算面積毫無概念。東納德的朋友華生發現圍籬可能是由專精於計算幾何的電腦科學家建造的,因為下列事實絕非巧合:

  • 外層圍籬之內的土地,形成一個完美的圓形$C$。以下用$B$代表$C$邊界上的所有點所形成的集合。
  • 內層圍籬之內的土地,形成一個非自交$n$邊形$P$,即不共用頂點的兩條邊,沒有交點。以下用$V$代表$P$的所有頂點所形成的集合。
  • $P$所有頂點到$C$的最短距離都是一樣的,即對$V$中相異的兩頂點$(x_u,y_u),(x_v,y_v)$,下述等式成立: $$\min_{(x,y)\in B}\sqrt{(x-x_u)^2+(y-y_u)^2}=\min_{(x,y)\in B}\sqrt{(x-x_v)^2+(y-y_v)^2}.$$

你恍然大悟。你明白了如何由外層圍籬總長$c$以及內層圍籬的$n$個邊長$\ell_1,\dots,\ell_n$ 計算出兩個圍籬之間的土地面積。還記得東納德知道如何測量圍籬長度吧?請幫他算出面積吧。

中文輸入說明

輸入的第一行有一個正整數$T$代表有多少筆測試資料。每一筆測試資料有兩行,第一行有兩個數字$c$ 跟 $n$,以一個空白隔開。$c$代表了外層圍籬的總長,也就是$C$的周長。$n$代表內層圍籬的頂點數目。第二行有$n$個正整數$\ell_1,\dots,\ell_n$,代表$n$邊形$P$的各個邊長。

可假設:

  • $1 \le T \le 100$
  • $3 \le n \le 10$
  • $10 \le c \le 1000$
  • $\ell_1,\dots,\ell_n>0$
  • $P$必在圓$C$內部。

中文輸出說明

對每筆測試資料,請輸出兩層圍籬間的土地面積。只要絕對或相對誤差小於$10^{-6}$就會被視為正確。


Judge Setting

run-time limit: 3000 ms
memory limit: 65536000 byte
測資數量: 0