結果
| 問題 | No.1688 Veterinarian |
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2021-09-04 08:03:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 608 ms / 3,000 ms |
| コード長 | 2,115 bytes |
| 記録 | |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 82,052 KB |
| 最終ジャッジ日時 | 2024-07-05 09:52:30 |
| 合計ジャッジ時間 | 3,162 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
import sys
from collections import defaultdict, Counter, deque
from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate
import operator
from math import sqrt, gcd, factorial
# from math import isqrt, prod,comb # python3.8用(notpypy)
#from bisect import bisect_left,bisect_right
#from functools import lru_cache,reduce
#from heapq import heappush,heappop,heapify,heappushpop,heapreplace
#import numpy as np
#import networkx as nx
#from networkx.utils import UnionFind
#from numba import njit, b1, i1, i4, i8, f8
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, NegativeCycleError
# numba例 @njit(i1(i4[:], i8[:, :]),cache=True) 引数i4配列、i8 2次元配列,戻り値i1
def input(): return sys.stdin.readline().rstrip()
def divceil(n, k): return 1+(n-1)//k # n/kの切り上げを返す
def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no)
def main():
a,b,c,n=map(int, input().split())
dpa=[[[0.0]*c for _ in range(b)] for _ in range(a)]
dpb=[[[0.0]*c for _ in range(b)] for _ in range(a)]
dpc=[[[0.0]*c for _ in range(b)] for _ in range(a)]
for nn in range(1,n+1):
for aa in reversed(range(a)):
for bb in reversed(range(b)):
for cc in reversed(range(c)):
num=aa+bb+cc+3
aprob=(aa*(aa+1))/(num*(num-1))
bprob=(bb*(bb+1))/(num*(num-1))
cprob=(cc*(cc+1))/(num*(num-1))
noprob=1-aprob-bprob-cprob
dpa[aa][bb][cc]=noprob*dpa[aa][bb][cc]+aprob*(dpa[aa-1][bb][cc]+1)+bprob*dpa[aa][bb-1][cc]+cprob*dpa[aa][bb][cc-1]
dpb[aa][bb][cc]=noprob*dpb[aa][bb][cc]+aprob*dpb[aa-1][bb][cc]+bprob*(dpb[aa][bb-1][cc]+1)+cprob*dpb[aa][bb][cc-1]
dpc[aa][bb][cc]=noprob*dpc[aa][bb][cc]+aprob*dpc[aa-1][bb][cc]+bprob*dpc[aa][bb-1][cc]+cprob*(dpc[aa][bb][cc-1]+1)
print(dpa[-1][-1][-1],dpb[-1][-1][-1],dpc[-1][-1][-1])
if __name__ == '__main__':
main()
LayCurse