# 找到多边形的面积

9

``````[3, 4, 5] --> 6
[3, 4, 6] --> 5.332682251925386
[3, 4, 6, 7] --> 22.44994432064365
[5, 5, 5, 5] --> 25
[6, 6, 6, 6, 6] --> 61.93718642120281
[6.974973020933265, 2.2393294197257387, 5.158285083300981, 1.4845682771595603, 3.5957940796134173] --> 21.958390804292847
[7.353566082457831, 12.271766915518073, 8.453884922273897, 9.879017670784675, 9.493366404245332, 1.2050010402321778] --> 162.27641678140589
``````

7

mIllIbyte

1

Luis Mendo

poi830 '16

5

# Python 2，191字节

``````from math import*
C=sorted(input());l,h=C[-1]/2,sum(C)
while h-l>1e-9:m=l+h;a=[asin(c/m)for c in C[:-1]];f=pi-sum(a);l,h=[l,m/2,h][m*sin(f)<C[-1]:][:2]
print sum(l*l*sin(2*t)for t in a+[f])/2
``````

``````import math

def segment_angles(line_segments, r):
return [2*math.asin(c/(2*r)) for c in line_segments]

def cyclic_ngon_area(line_segments):
line_segments = list(sorted(line_segments))
lo, hi = max(line_segments) / 2, sum(line_segments)
while hi - lo > 1e-9:
mid = (lo + hi) / 2
angles = segment_angles(line_segments[:-1], mid)
angles.append(2*math.pi - sum(angles))
if 2 * mid * math.sin(angles[-1]/2) < line_segments[-1]:
lo = mid
else:
hi = mid
return sum([lo*lo * math.sin(a) / 2 for a in angles])
``````

soktinpk

@soktinpk我固定了我的答案。
orlp

0

# 八度，89字节

``````r=sum(s=input(''));while sum(a=asin(s/2/r))<pi r*=1-1e-4;b=a;end;disp(sum(cos(b).*s/2*r))
``````

## 说明

### 算法

1. 设置`r`为太大的东西，例如周长。
2. 如果累积角度小于`2pi`，请减小`r`并重复步骤2。
3. 计算面积。

soktinpk

orlp

@soktinpk大约为15000，最大为`r*=1-1e-4`150000 `r*=1-1e-5`
Rainer P.

@RainerP。这两个值是相同的。
Fund Monica的诉讼

1
@soktinpk通常不建议对特定答案作例外处理。
Cyoce '16