結果
問題 | No.1688 Veterinarian |
ユーザー | mymelochan |
提出日時 | 2021-09-25 00:25:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 723 ms / 3,000 ms |
コード長 | 1,505 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 118,124 KB |
最終ジャッジ日時 | 2024-07-05 11:41:55 |
合計ジャッジ時間 | 3,794 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
66,688 KB |
testcase_01 | AC | 80 ms
83,832 KB |
testcase_02 | AC | 64 ms
79,104 KB |
testcase_03 | AC | 50 ms
66,816 KB |
testcase_04 | AC | 49 ms
66,560 KB |
testcase_05 | AC | 48 ms
66,432 KB |
testcase_06 | AC | 90 ms
84,312 KB |
testcase_07 | AC | 134 ms
82,348 KB |
testcase_08 | AC | 723 ms
118,124 KB |
testcase_09 | AC | 663 ms
117,076 KB |
testcase_10 | AC | 182 ms
89,556 KB |
testcase_11 | AC | 206 ms
88,168 KB |
testcase_12 | AC | 99 ms
80,256 KB |
testcase_13 | AC | 118 ms
86,400 KB |
testcase_14 | AC | 137 ms
83,584 KB |
testcase_15 | AC | 174 ms
90,492 KB |
testcase_16 | AC | 101 ms
82,084 KB |
ソースコード
A,B,C,N = map(int,input().split()) dp = [[[0]*51 for _ in range(51)] for _ in range(51)] dp[A][B][C] = 1 def precomb(N): pascal = [0]*(N+1) pascal[0] = [1] pascal[1] = [1,1] for i in range(2,N+1): res = [0]*(i+1) res[0] = res[-1] = 1 for j in range(len(pascal[i-1])-1): res[j+1] = (pascal[i-1][j]+pascal[i-1][j+1]) pascal[i] = res[:] return pascal pascal = precomb(200) for _ in range(N): ndp = [[[0]*51 for _ in range(51)] for _ in range(51)] for a in range(A+1): for b in range(B+1): for c in range(C+1): s = a+b+c if s < 2: continue div = pascal[s][2] tdp = dp[a][b][c] t = 0 if a >= 2: u = pascal[a][2] t += u ndp[a-1][b][c] += tdp*u/div if b >= 2: u = pascal[b][2] t += u ndp[a][b-1][c] += tdp*u/div if c >= 2: u = pascal[c][2] t += u ndp[a][b][c-1] += tdp*u/div ndp[a][b][c] += tdp*(div-t)/div dp = ndp ans_a = 0 ans_b = 0 ans_c = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): tdp = dp[a][b][c] ans_a += (A-a)*tdp ans_b += (B-b)*tdp ans_c += (C-c)*tdp print(ans_a,ans_b,ans_c)