結果

問題 No.1688 Veterinarian
ユーザー mkawa2mkawa2
提出日時 2021-09-24 21:57:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 897 ms / 3,000 ms
コード長 1,423 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 89,820 KB
最終ジャッジ日時 2023-09-18 21:17:59
合計ジャッジ時間 3,692 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,732 KB
testcase_01 AC 21 ms
8,868 KB
testcase_02 AC 21 ms
8,940 KB
testcase_03 AC 21 ms
8,692 KB
testcase_04 AC 21 ms
8,692 KB
testcase_05 AC 20 ms
8,804 KB
testcase_06 AC 23 ms
9,112 KB
testcase_07 AC 21 ms
8,740 KB
testcase_08 AC 897 ms
89,820 KB
testcase_09 AC 830 ms
84,548 KB
testcase_10 AC 169 ms
23,936 KB
testcase_11 AC 59 ms
12,956 KB
testcase_12 AC 20 ms
8,744 KB
testcase_13 AC 52 ms
12,460 KB
testcase_14 AC 21 ms
8,792 KB
testcase_15 AC 273 ms
36,308 KB
testcase_16 AC 21 ms
8,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from functools import lru_cache

a, b, c, n = LI()

@lru_cache(None)
def ev(i, j, k, t):
    if t == 0: return 0, 0, 0
    s = i+j+k
    if s < 2: return 0, 0, 0
    ni = nj = nk = 0
    sp = 0
    if i > 1:
        p = i*(i-1)/s/(s-1)
        sp += p
        ri, rj, rk = ev(i-1, j, k, t-1)
        ni += (ri+1)*p
        nj += rj*p
        nk += rk*p
    if j > 1:
        p = j*(j-1)/s/(s-1)
        sp += p
        ri, rj, rk = ev(i, j-1, k, t-1)
        ni += ri*p
        nj += (rj+1)*p
        nk += rk*p
    if k > 1:
        p = k*(k-1)/s/(s-1)
        sp += p
        ri, rj, rk = ev(i, j, k-1, t-1)
        ni += ri*p
        nj += rj*p
        nk += (rk+1)*p
    p = 1-sp
    ri, rj, rk = ev(i, j, k, t-1)
    ni += ri*p
    nj += rj*p
    nk += rk*p
    return ni, nj, nk

print(*ev(a, b, c, n))
0