結果

問題 No.1688 Veterinarian
ユーザー gr1msl3ygr1msl3y
提出日時 2022-02-24 00:00:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 996 ms / 3,000 ms
コード長 899 bytes
コンパイル時間 1,325 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 133,500 KB
最終ジャッジ日時 2023-09-14 17:03:10
合計ジャッジ時間 6,143 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,420 KB
testcase_01 AC 74 ms
74,920 KB
testcase_02 AC 77 ms
74,792 KB
testcase_03 AC 72 ms
71,304 KB
testcase_04 AC 74 ms
71,068 KB
testcase_05 AC 75 ms
71,328 KB
testcase_06 AC 92 ms
76,540 KB
testcase_07 AC 73 ms
71,604 KB
testcase_08 AC 996 ms
133,500 KB
testcase_09 AC 910 ms
129,280 KB
testcase_10 AC 296 ms
87,476 KB
testcase_11 AC 170 ms
79,776 KB
testcase_12 AC 76 ms
71,512 KB
testcase_13 AC 173 ms
79,732 KB
testcase_14 AC 79 ms
75,072 KB
testcase_15 AC 395 ms
91,512 KB
testcase_16 AC 78 ms
75,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B, C, N = map(int, input().split())
X = [A, B, C]
dp = {(A, B, C): 1.0}
for _ in range(N):
    ndp = {}
    for a, b, c in dp:
        s = a+b+c
        if a > 1:
            if (a-1, b, c) not in ndp:
                ndp[(a-1, b, c)] = 0.0
            ndp[(a-1, b, c)] += dp[(a, b, c)]*a*(a-1)/s/(s-1)
        if b > 1:
            if (a, b-1, c) not in ndp:
                ndp[(a, b-1, c)] = 0.0
            ndp[(a, b-1, c)] += dp[(a, b, c)]*b*(b-1)/s/(s-1)
        if c > 1:
            if (a, b, c-1) not in ndp:
                ndp[(a, b, c-1)] = 0.0
            ndp[(a, b, c-1)] += dp[(a, b, c)]*c*(c-1)/s/(s-1)
        if (a, b, c) not in ndp:
            ndp[(a, b, c)] = 0.0
        ndp[(a, b, c)] += dp[(a, b, c)] * \
            (s*(s-1)-a*(a-1)-b*(b-1)-c*(c-1))/s/(s-1)
    dp = ndp

ans = [0.0]*3
for t in dp:
    for i in range(3):
        ans[i] += dp[t]*(X[i]-t[i])

print(*ans)
0