QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#863736#3001. Piece of CakeisWFnoya#Compile Error//C++232.2kb2025-01-19 21:49:162025-01-19 21:49:17

Judging History

你现在查看的是最新测评结果

  • [2025-01-19 21:49:17]
  • 评测
  • [2025-01-19 21:49:16]
  • 提交

answer

import math

eps = 1e-9
pi = math.acos(-1.0)
inf = 40000

def sgn(x):
    if x < -eps:
        return -1
    elif x > eps:
        return 1
    else:
        return 0

def cmp(x, y):
    return sgn(x - y)

def C(n, m):
    if n <= m:
        return 1.0
    return fac[n] / fac[m] / fac[n - m]

# 定义一个类来表示二维点
class Point:
    def __init__(self, x=0.0, y=0.0):
        self.x = x
        self.y = y

    def input(self):
        x2, y2 = map(float, input().split())
        self.x = x2
        self.y = y2

    def __add__(self, s):
        return Point(self.x + s.x, self.y + s.y)

    def __sub__(self, s):
        return Point(self.x - s.x, self.y - s.y)

    def __mul__(self, k):
        return Point(self.x * k, self.y * k)

    def __truediv__(self, k):
        return Point(self.x / k, self.y / k)

    def dot(self, a):
        return self.x * a.x + self.y * a.y

    def cross(self, a):
        return self.x * a.y - self.y * a.x

def cross(s, t):
    return s.x * t.y - s.y * t.x

# 计算组合数 C(n, m)
fac = [1] * 3000
for i in range(1, 3000):
    fac[i] = fac[i - 1] * i

def solve():
    # 预先计算所有的阶乘
    fac[0] = 1
    for i in range(1, 3000):
        fac[i] = fac[i - 1] * i

    # 计算组合数 C(1000, 900)
    # print(f"{C(1000, 900):.8f}")
    # return

    # 读取 n 和 k
    n, k = map(int, input().split())
    # n = 3000
    # k = 10
    p = []

    # 输入所有的点
    for i in range(n):
        point = Point()
        point.input()
        p.append(point)

    p.reverse()  # 反转点列表

    ans = 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 * fac[cnt] / fac[cnt - (k - 2)]
            
            cnt = j - i - 1
            if cnt >= k - 2:
                ans -= c * fac[cnt] / fac[cnt - (k - 2)]

    # 输出最终结果,使用 8 位小数
    result = ans / 2.0 / fac[k - 2] / C(n, k)
    print(f"{result:.8f}")

if __name__ == "__main__":
    T = 1
    # T = int(input())  # 可选输入多个测试案例
    while T > 0:
        solve()
        T -= 1

Details

answer.code:23:3: error: invalid preprocessing directive #\U00005b9a\U00004e49\U00004e00\U00004e2a\U00007c7b\U00006765\U00008868\U0000793a\U00004e8c\U00007ef4\U000070b9
   23 | # 定义一个类来表示二维点
      |   ^~~~~~~~~~~~~~~~~~~~~~
answer.code:55:3: error: invalid preprocessing directive #\U00008ba1\U00007b97\U00007ec4\U00005408\U00006570
   55 | # 计算组合数 C(n, m)
      |   ^~~~~~~~~~
answer.code:61:7: error: invalid preprocessing directive #\U00009884\U00005148\U00008ba1\U00007b97\U00006240\U00006709\U00007684\U00009636\U00004e58
   61 |     # 预先计算所有的阶乘
      |       ^~~~~~~~~~~~~~~~~~
answer.code:66:7: error: invalid preprocessing directive #\U00008ba1\U00007b97\U00007ec4\U00005408\U00006570
   66 |     # 计算组合数 C(1000, 900)
      |       ^~~~~~~~~~
answer.code:67:7: error: invalid preprocessing directive #print
   67 |     # print(f"{C(1000, 900):.8f}")
      |       ^~~~~
answer.code:68:7: error: invalid preprocessing directive #return
   68 |     # return
      |       ^~~~~~
answer.code:70:7: error: invalid preprocessing directive #\U00008bfb\U000053d6
   70 |     # 读取 n 和 k
      |       ^~~~
answer.code:72:7: error: invalid preprocessing directive #n
   72 |     # n = 3000
      |       ^
answer.code:73:7: error: invalid preprocessing directive #k
   73 |     # k = 10
      |       ^
answer.code:76:7: error: invalid preprocessing directive #\U00008f93\U00005165\U00006240\U00006709\U00007684\U000070b9
   76 |     # 输入所有的点
      |       ^~~~~~~~~~~~
answer.code:82:18: error: stray ‘#’ in program
   82 |     p.reverse()  # 反转点列表
      |                  ^
answer.code:96:7: error: invalid preprocessing directive #\U00008f93\U000051fa\U00006700\U00007ec8\U00007ed3\U0000679c\U0000ff0c\U00004f7f\U00007528
   96 |     # 输出最终结果,使用 8 位小数
      |       ^~~~~~~~~~~~~~~~~~
answer.code:102:7: error: invalid preprocessing directive #T
  102 |     # T = int(input())  # 可选输入多个测试案例
      |       ^
answer.code:1:1: error: ‘import’ does not name a type
    1 | import math
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’