QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227174 | #6801. Blackjack | jzh | RE | 35ms | 15388kb | Python3 | 1.1kb | 2023-10-27 00:52:24 | 2023-10-27 00:52:24 |
Judging History
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+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 = [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+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: 35ms
memory: 15388kb
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: 30ms
memory: 15360kb
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