結果

問題 No.1688 Veterinarian
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-24 22:33:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 663 ms / 3,000 ms
コード長 643 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 130,352 KB
最終ジャッジ日時 2023-09-18 21:48:03
合計ジャッジ時間 5,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,436 KB
testcase_01 AC 101 ms
76,340 KB
testcase_02 AC 111 ms
77,008 KB
testcase_03 AC 95 ms
71,828 KB
testcase_04 AC 94 ms
71,716 KB
testcase_05 AC 94 ms
71,868 KB
testcase_06 AC 663 ms
130,352 KB
testcase_07 AC 95 ms
71,956 KB
testcase_08 AC 618 ms
130,352 KB
testcase_09 AC 585 ms
125,952 KB
testcase_10 AC 218 ms
85,484 KB
testcase_11 AC 145 ms
79,176 KB
testcase_12 AC 92 ms
71,716 KB
testcase_13 AC 167 ms
80,528 KB
testcase_14 AC 98 ms
76,348 KB
testcase_15 AC 478 ms
114,092 KB
testcase_16 AC 99 ms
76,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c, n = map(int, input().split())
from collections import defaultdict
dp = defaultdict(lambda: 0)
dp[(a, b, c)] = 1
for i in range(n):
    nx = defaultdict(lambda: 0)
    for (x, y, z), p in dp.items():
        t = (x+y+z)*(x+y+z-1)//2
        if t == 0:
            continue
        px = x*(x-1)//2
        nx[(x-1, y, z)] += (px/t)*p
        py = y*(y-1)//2
        nx[(x, y-1, z)] += (py/t)*p
        pz = z*(z-1)//2
        nx[(x, y, z-1)] += (pz/t)*p
        nx[(x, y, z)] += ((t-px-py-pz)/t)*p
    dp = nx
ans = [0, 0, 0]
for (x, y, z), p in dp.items():
    ans[0] += (a-x)*p
    ans[1] += (b-y)*p
    ans[2] += (c-z)*p
print(*ans)
0