結果
| 問題 | No.1688 Veterinarian | 
| コンテスト | |
| ユーザー |  brthyyjp | 
| 提出日時 | 2021-09-24 22:33:46 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 592 ms / 3,000 ms | 
| コード長 | 643 bytes | 
| コンパイル時間 | 270 ms | 
| コンパイル使用メモリ | 81,856 KB | 
| 実行使用メモリ | 128,348 KB | 
| 最終ジャッジ日時 | 2024-07-05 10:59:22 | 
| 合計ジャッジ時間 | 4,142 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
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)
            
            
            
        