結果
問題 | No.1688 Veterinarian |
ユーザー | LayCurse |
提出日時 | 2021-09-04 08:03:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 689 ms / 3,000 ms |
コード長 | 2,115 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 87,264 KB |
実行使用メモリ | 83,104 KB |
最終ジャッジ日時 | 2023-09-18 20:27:17 |
合計ジャッジ時間 | 4,767 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
71,888 KB |
testcase_01 | AC | 94 ms
71,524 KB |
testcase_02 | AC | 96 ms
71,560 KB |
testcase_03 | AC | 95 ms
71,484 KB |
testcase_04 | AC | 93 ms
71,612 KB |
testcase_05 | AC | 95 ms
71,408 KB |
testcase_06 | AC | 113 ms
77,280 KB |
testcase_07 | AC | 157 ms
81,796 KB |
testcase_08 | AC | 689 ms
83,104 KB |
testcase_09 | AC | 643 ms
82,956 KB |
testcase_10 | AC | 201 ms
79,492 KB |
testcase_11 | AC | 207 ms
79,552 KB |
testcase_12 | AC | 145 ms
78,880 KB |
testcase_13 | AC | 163 ms
78,052 KB |
testcase_14 | AC | 150 ms
78,492 KB |
testcase_15 | AC | 186 ms
78,488 KB |
testcase_16 | AC | 122 ms
78,104 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)] 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()