結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-09-24 23:07:41 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 803 bytes |
| コンパイル時間 | 77 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 103,852 KB |
| 最終ジャッジ日時 | 2024-07-05 11:24:25 |
| 合計ジャッジ時間 | 11,082 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 14 |
ソースコード
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))
titia