結果

問題 No.574 正多面体サイコロ
ユーザー nisizawanisizawa
提出日時 2017-12-20 18:52:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 9,008 KB
最終ジャッジ日時 2023-08-22 10:58:06
合計ジャッジ時間 2,114 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,780 KB
testcase_01 AC 33 ms
8,840 KB
testcase_02 AC 25 ms
8,832 KB
testcase_03 AC 22 ms
8,848 KB
testcase_04 AC 18 ms
8,892 KB
testcase_05 AC 32 ms
8,884 KB
testcase_06 AC 20 ms
8,872 KB
testcase_07 AC 23 ms
8,872 KB
testcase_08 AC 19 ms
8,808 KB
testcase_09 AC 46 ms
8,868 KB
testcase_10 AC 46 ms
8,976 KB
testcase_11 AC 20 ms
8,876 KB
testcase_12 AC 26 ms
8,876 KB
testcase_13 AC 21 ms
8,800 KB
testcase_14 AC 26 ms
8,908 KB
testcase_15 AC 21 ms
8,828 KB
testcase_16 AC 19 ms
9,000 KB
testcase_17 AC 29 ms
8,884 KB
testcase_18 AC 43 ms
8,900 KB
testcase_19 AC 22 ms
9,008 KB
testcase_20 AC 20 ms
8,696 KB
testcase_21 AC 20 ms
8,628 KB
testcase_22 AC 98 ms
8,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

@lru_cache(maxsize=None)
def fact(n):
    return 1 if n == 0 else n * fact(n - 1)

f, n, k = map(int, input().split())

e = 0
for x in range(1, f + 1):
    p_l = (x - 1) / f
    p_c = 1 / f
    p_r = (f - x) / f
    
    p = 0
    for l in range(n - k + 1):
        for r in range(k):
            c = n - l - r
            p += p_l**l * p_c**c * p_r**r * fact(n) / (fact(l) * fact(c) * fact(r))
    
    e += p * x

print(e)
0