結果
問題 | No.1688 Veterinarian |
ユーザー | ansain |
提出日時 | 2021-05-29 19:47:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,503 ms / 3,000 ms |
コード長 | 2,247 bytes |
コンパイル時間 | 658 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 264,244 KB |
最終ジャッジ日時 | 2024-07-05 09:47:54 |
合計ジャッジ時間 | 5,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
53,888 KB |
testcase_01 | AC | 45 ms
54,656 KB |
testcase_02 | AC | 47 ms
54,784 KB |
testcase_03 | AC | 44 ms
53,632 KB |
testcase_04 | AC | 45 ms
53,888 KB |
testcase_05 | AC | 45 ms
53,888 KB |
testcase_06 | AC | 71 ms
68,992 KB |
testcase_07 | AC | 136 ms
85,268 KB |
testcase_08 | AC | 1,503 ms
264,244 KB |
testcase_09 | AC | 1,424 ms
250,444 KB |
testcase_10 | AC | 211 ms
92,284 KB |
testcase_11 | AC | 240 ms
95,208 KB |
testcase_12 | AC | 110 ms
77,988 KB |
testcase_13 | AC | 125 ms
79,384 KB |
testcase_14 | AC | 122 ms
80,152 KB |
testcase_15 | AC | 182 ms
86,400 KB |
testcase_16 | AC | 75 ms
70,144 KB |
ソースコード
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)] for _ in range(n+1)] dpb=[[[[0.0]*c for _ in range(b)] for _ in range(a)] for _ in range(n+1)] dpc=[[[[0.0]*c for _ in range(b)] for _ in range(a)] for _ in range(n+1)] for nn in range(1,n+1): for aa in range(a): for bb in range(b): for cc in 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[nn][aa][bb][cc]=noprob*dpa[nn-1][aa][bb][cc]+aprob*(dpa[nn-1][aa-1][bb][cc]+1)+bprob*dpa[nn-1][aa][bb-1][cc]+cprob*dpa[nn-1][aa][bb][cc-1] dpb[nn][aa][bb][cc]=noprob*dpb[nn-1][aa][bb][cc]+aprob*dpb[nn-1][aa-1][bb][cc]+bprob*(dpb[nn-1][aa][bb-1][cc]+1)+cprob*dpb[nn-1][aa][bb][cc-1] dpc[nn][aa][bb][cc]=noprob*dpc[nn-1][aa][bb][cc]+aprob*dpc[nn-1][aa-1][bb][cc]+bprob*dpc[nn-1][aa][bb-1][cc]+cprob*(dpc[nn-1][aa][bb][cc-1]+1) print(dpa[-1][-1][-1][-1],dpb[-1][-1][-1][-1],dpc[-1][-1][-1][-1]) if __name__ == '__main__': main()