結果

問題 No.574 正多面体サイコロ
ユーザー maspy
提出日時 2020-02-26 22:52:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 578 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,464 KB
最終ジャッジ日時 2024-10-13 15:33:35
合計ジャッジ時間 12,339 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
import numpy as np
F, N, K = map(int, read().split())


# %%
x = np.arange(N + 1).astype(np.float64)
x[0] = 1
fact = np.multiply.accumulate(x)
comb = fact[N] / fact / fact[::-1]


# %%
P = [sum(comb[i] * (F - x) ** i * x ** (N - i) for i in range(K)) for x in range(F + 1)]
answer = F + 1 - sum(P) / P[-1]
print(answer)
0