結果

問題 No.108 トリプルカードコンプ
ユーザー nisshy_280
提出日時 2022-12-14 15:41:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 420 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 42,048 KB
最終ジャッジ日時 2024-11-08 07:42:40
合計ジャッジ時間 2,723 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=100001)

def solve(x,y,z):
    if x==n and y==n and z==n:
        return 0
    exp = n/(n-z)
    res = 0
    if x != n:
        res += (solve(x+1,y,z)+exp)*(n-x)/(n-z)
    if y != x:
        res += (solve(x,y+1,z)+exp)*(x-y)/(n-z)
    if z != y:
        res += (solve(x,y,z+1)+exp)*(y-z)/(n-z)
    return res

n = int(input())
A = list(map(int,input().split()))
count = [0,0,0]
for i in A:
    if i >= 1:
        count[0] += 1
    if i >= 2:
        count[1] += 1
    if i >= 3:
        count[2] += 1
print(solve(count[0],count[1],count[2]))
0