結果

問題 No.1688 Veterinarian
ユーザー rlangevinrlangevin
提出日時 2023-02-14 22:56:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 554 ms / 3,000 ms
コード長 1,253 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 187,672 KB
最終ジャッジ日時 2023-09-24 09:55:20
合計ジャッジ時間 4,964 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
80,040 KB
testcase_01 AC 178 ms
187,672 KB
testcase_02 AC 123 ms
106,684 KB
testcase_03 AC 87 ms
79,808 KB
testcase_04 AC 88 ms
79,960 KB
testcase_05 AC 94 ms
79,996 KB
testcase_06 AC 209 ms
165,368 KB
testcase_07 AC 135 ms
80,452 KB
testcase_08 AC 554 ms
116,976 KB
testcase_09 AC 540 ms
114,904 KB
testcase_10 AC 238 ms
131,168 KB
testcase_11 AC 225 ms
105,704 KB
testcase_12 AC 154 ms
82,948 KB
testcase_13 AC 192 ms
111,828 KB
testcase_14 AC 170 ms
92,616 KB
testcase_15 AC 252 ms
172,648 KB
testcase_16 AC 163 ms
95,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(a, b, c):
    return a * 52 * 52 + b * 52 + c

A, B, C, N = map(int, input().split())
pre = [0] * (52 * 52 * 52)
pre[0] = 1
for i in range(N):
    dp = [0] * (52 * 52 * 52)
    for a in range(51):
        if A - a < 0:
            continue
        for b in range(51):
            if B - b < 0:
                continue
            for c in range(51):
                if C - c < 0:
                    continue
                all = A - a + B - b + C - c
                if all <= 1:
                    continue
                pa = (A - a) * (A - a - 1) / (all * (all - 1))
                pb = (B - b) * (B - b - 1) / (all * (all - 1))
                pc = (C - c) * (C - c - 1) / (all * (all - 1))
                dp[f(a + 1,b,c)] += pre[f(a,b,c)] * pa
                dp[f(a,b + 1,c)] += pre[f(a,b,c)] * pb
                dp[f(a,b,c + 1)] += pre[f(a,b,c)] * pc
                dp[f(a,b,c)] += pre[f(a,b,c)] * (1 - pa - pb - pc)
                
    dp, pre = pre, dp
    
                    
ansA, ansB, ansC = 0, 0, 0
for a in range(51):
    for b in range(51):
        for c in range(51):
            ansA += pre[f(a,b,c)] * a
            ansB += pre[f(a,b,c)] * b
            ansC += pre[f(a,b,c)] * c
            
print(ansA, ansB, ansC)
0