QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227332#6801. BlackjackjzhCompile Error//Python31.1kb2023-10-27 12:26:362023-10-27 12:26:36

Judging History

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

  • [2023-10-27 12:26:36]
  • 评测
  • [2023-10-27 12:26:36]
  • 提交

answer

 import copy

maxn = 505
db = float

def solve():
    n, a, b = map(int, input().split())
    vec = [0] + list(map(int, input().split()))  # 在vec前加一个0以保持与C++索引一致

    dp = [([0.0] * (maxn)) for _ in range(maxn)]

    dp[0][0] = 1.0

    for i in range(1, n+1):
        ndp = [([0.0] * (maxn)) for _ in range(maxn)]
        for x in range(i):
            for y in range(b+1):
                ndp[x][y] += dp[x][y]
                if y + vec[i] <= b:
                    ndp[x+1][y + vec[i]] += dp[x][y] * (x+1) / (n-x)
        # print(ndp[0][0])
        dp = [row[:] for row in ndp]

    ans = 0.0
    for i in range(1, n+1):
        ndp = [row[:] for row in dp]
        for x in range(n):
            for y in range(b-vec[i]+1):
                ndp[x+1][y+vec[i]] -= ndp[x][y] * (x+1) / (n-x)
        temp = 0.0
        for x in range(n):
            for y in range(a+1):
                if y + vec[i] > a and y + vec[i] <= b:
                    temp += ndp[x][y] / (n-x)
        ans += temp

    print('{:.50f}'.format(ans))

solve()

詳細信息

Sorry: IndentationError: unexpected indent (answer.code, line 1)