QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227160#6801. BlackjackjzhRE 591ms14824kbPython31.1kb2023-10-27 00:03:502023-10-27 00:03:51

Judging History

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

  • [2023-10-27 00:03:51]
  • 评测
  • 测评结果:RE
  • 用时:591ms
  • 内存:14824kb
  • [2023-10-27 00:03:50]
  • 提交

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)]
    ndp = [([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+1):
            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 = copy.deepcopy(ndp)

    ans = 0.0
    for i in range(1, n+1):
        ndp = copy.deepcopy(dp)  # 使用深拷贝确保数组复制
        for x in range(n):
            for y in range(b+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()

詳細信息

Test #1:

score: 100
Accepted
time: 591ms
memory: 14824kb

input:

5 2 4
1 1 1 5 5

output:

0.10000000000000000555111512312578270211815834045410

result:

ok found '0.1000000', expected '0.1000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 590ms
memory: 14788kb

input:

5 2 4
1 1 1 3 5

output:

0.45000000000000006661338147750939242541790008544922

result:

ok found '0.4500000', expected '0.4500000', error '0.0000000'

Test #3:

score: -100
Dangerous Syscalls

input:

18 10 11
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

output:


result: