結果
問題 | No.1688 Veterinarian |
ユーザー | ansain |
提出日時 | 2021-05-29 19:47:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,611 ms / 3,000 ms |
コード長 | 2,247 bytes |
コンパイル時間 | 1,047 ms |
コンパイル使用メモリ | 86,976 KB |
実行使用メモリ | 265,728 KB |
最終ジャッジ日時 | 2023-09-18 20:21:44 |
合計ジャッジ時間 | 7,242 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 95 ms
71,356 KB |
testcase_01 | AC | 98 ms
71,788 KB |
testcase_02 | AC | 100 ms
72,600 KB |
testcase_03 | AC | 97 ms
71,728 KB |
testcase_04 | AC | 98 ms
71,548 KB |
testcase_05 | AC | 97 ms
71,604 KB |
testcase_06 | AC | 117 ms
78,344 KB |
testcase_07 | AC | 178 ms
85,832 KB |
testcase_08 | AC | 1,611 ms
265,728 KB |
testcase_09 | AC | 1,490 ms
251,796 KB |
testcase_10 | AC | 261 ms
93,836 KB |
testcase_11 | AC | 287 ms
95,672 KB |
testcase_12 | AC | 150 ms
78,856 KB |
testcase_13 | AC | 163 ms
80,284 KB |
testcase_14 | AC | 165 ms
80,976 KB |
testcase_15 | AC | 222 ms
88,276 KB |
testcase_16 | AC | 121 ms
78,504 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()