結果

問題 No.1688 Veterinarian
ユーザー wolgnikwolgnik
提出日時 2021-09-24 22:16:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 646 ms / 3,000 ms
コード長 1,057 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 122,692 KB
最終ジャッジ日時 2023-09-18 21:34:31
合計ジャッジ時間 4,824 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,416 KB
testcase_01 AC 73 ms
71,272 KB
testcase_02 AC 76 ms
71,160 KB
testcase_03 AC 73 ms
71,308 KB
testcase_04 AC 73 ms
71,296 KB
testcase_05 AC 74 ms
71,620 KB
testcase_06 AC 97 ms
77,064 KB
testcase_07 AC 128 ms
80,356 KB
testcase_08 AC 646 ms
122,692 KB
testcase_09 AC 609 ms
117,680 KB
testcase_10 AC 179 ms
79,304 KB
testcase_11 AC 185 ms
79,452 KB
testcase_12 AC 114 ms
78,120 KB
testcase_13 AC 122 ms
78,188 KB
testcase_14 AC 137 ms
79,004 KB
testcase_15 AC 153 ms
78,372 KB
testcase_16 AC 117 ms
77,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
A, B, C, N = map(int, input().split())

dp = [[[0.] * (C + 1) for _ in range(B + 1)] for _ in range(A + 1)]
dp[-1][-1][-1] = 1.
#print(dp)
for _ in range(N):
  ndp = [[[0.] * (C + 1) for _ in range(B + 1)] for _ in range(A + 1)]
  for x in range(A + 1):
    for y in range(B + 1):
      for z in range(C + 1):
        sm = x + y + z
        #print(x, y, z, sm)
        if sm >= 2:
          a = x * (x - 1) / sm / (sm - 1)
          b = y * (y - 1) / sm / (sm - 1)
          c = z * (z - 1) / sm / (sm - 1)
          ndp[x - 1][y][z] += dp[x][y][z] * a
          ndp[x][y - 1][z] += dp[x][y][z] * b
          ndp[x][y][z - 1] += dp[x][y][z] * c
          #print(a,b,c,dp[x][y][z])
          ndp[x][y][z] += dp[x][y][z] * (1 - a - b - c)
        else: ndp[x][y][z] += dp[x][y][z]
  dp = ndp
  #print(dp)

res = [0.] * 3
for x in range(A + 1):
  for y in range(B + 1):
    for z in range(C + 1):
      res[0] += dp[x][y][z] * (A - x)
      res[1] += dp[x][y][z] * (B - y)
      res[2] += dp[x][y][z] * (C - z)
print(*res)
0