結果

問題 No.1688 Veterinarian
ユーザー titiatitia
提出日時 2021-09-24 23:07:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 101,560 KB
最終ジャッジ日時 2023-09-18 22:13:24
合計ジャッジ時間 13,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

A,B,C,N=map(int,input().split())

def c2(x):
    return x*(x-1)//2

def plus(A,B):
    ANS=[0,0,0]
    for i in range(3):
        ANS[i]=A[i]+B[i]

    return ANS

def mul(k,A):
    ANS=[0,0,0]
    for i in range(3):
        ANS[i]=k*A[i]
    return ANS
        
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(A,B,C,N):
    if N==0:
        return [0,0,0]
    ALL=c2(A+B+C)

    if ALL==0:
        return [0,0,0]

    ANS=[0,0,0]

    ANS=plus(ANS,mul(c2(A)/ALL,plus([1,0,0],calc(A-1,B,C,N-1))))
    ANS=plus(ANS,mul(c2(B)/ALL,plus([0,1,0],calc(A,B-1,C,N-1))))
    ANS=plus(ANS,mul(c2(C)/ALL,plus([0,0,1],calc(A,B,C-1,N-1))))
    ANS=plus(ANS,mul((ALL-c2(A)-c2(B)-c2(C))/ALL,calc(A,B,C,N-1)))

    return ANS
    
print(calc(A,B,C,N))
    
    
0