QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#863774 | #3001. Piece of Cake | isWFnoya# | RE | 0ms | 0kb | Python3 | 1.5kb | 2025-01-19 22:11:02 | 2025-01-19 22:11:04 |
answer
import math
import numpy as np
# 定义一个类来表示二维点
class Point:
def __init__(self, x=0.0, y=0.0):
self.x = np.float128(x)
self.y = np.float128(y)
def input(self):
x2, y2 = map(np.float128, input().split())
self.x = x2
self.y = y2
def cross(s, t):
return s.x * t.y - s.y * t.x
maxn = 2550
# 计算组合数 C(n, m)
C = [[np.float128(0)] * (_ + 1) for _ in range(maxn)]
for i in range(0, maxn):
for j in range(0 , i + 1):
if j == 0 or j == i:
C[i][j] = np.float128(1)
continue
if j <= i - 1:
C[i][j] = C[i - 1][j]
if j > 0:
C[i][j] += C[i - 1][j - 1]
def solve():
# 读取 n 和 k
n, k = map(int, input().split())
p = []
# 输入所有的点
for i in range(n):
point = Point()
point.input()
p.append(point)
p.reverse() # 反转点列表
ans = np.float128(0.0)
for i in range(n):
for j in range(i + 1, n):
c = cross(p[i], p[j])
cnt = n - (j - i + 1)
if cnt >= k - 2:
ans += c * C[cnt][k - 2]
cnt = j - i - 1
if cnt >= k - 2:
ans -= c * C[cnt][k - 2]
# 输出最终结果,使用 8 位小数
result = ans / 2 / C[n][k]
print(f"{result:.8f}")
if __name__ == "__main__":
T = 1
# T = int(input()) # 可选输入多个测试案例
while T > 0:
solve()
T -= 1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 3 -5.236334 -8.519438 -9.987847 -0.492878 -9.994555 0.329962