結果

問題 No.574 正多面体サイコロ
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 01:35:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 1,348 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 76,212 KB
最終ジャッジ日時 2023-09-10 23:14:54
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,932 KB
testcase_01 AC 72 ms
71,868 KB
testcase_02 AC 73 ms
71,640 KB
testcase_03 AC 71 ms
71,620 KB
testcase_04 AC 73 ms
71,872 KB
testcase_05 AC 71 ms
71,504 KB
testcase_06 AC 72 ms
71,640 KB
testcase_07 AC 71 ms
71,640 KB
testcase_08 AC 72 ms
71,844 KB
testcase_09 AC 73 ms
71,748 KB
testcase_10 AC 82 ms
76,212 KB
testcase_11 AC 72 ms
71,712 KB
testcase_12 AC 72 ms
71,664 KB
testcase_13 AC 72 ms
71,648 KB
testcase_14 AC 70 ms
71,684 KB
testcase_15 AC 73 ms
71,880 KB
testcase_16 AC 72 ms
71,616 KB
testcase_17 AC 72 ms
71,524 KB
testcase_18 AC 74 ms
72,004 KB
testcase_19 AC 72 ms
72,004 KB
testcase_20 AC 71 ms
71,880 KB
testcase_21 AC 71 ms
71,752 KB
testcase_22 AC 72 ms
71,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


def sub(x):
    if x==1:
        return 1
    v = 0
#     print(f,x)
    p = log(1 - (x-1)/f)
    p1 = log((x-1)/f) if x>1 else 0
#     print(x,p,p1)
    for i in range(k,n+1):
        v += exp(i*p + (n-i)*p1 + cmb(n,i))
    return v
f,n,k = list(map(int, input().split()))
"""数値計算する場合: 対数値を計算する
確率値に戻すときはexpをかませればOK
"""
from math import log, exp
N = n + f + 10 # 必要な最大サイズ
g1 = [0]
v = 0
for i in range(1, N+1):
    v += log(i)
    g1.append(v)
def cmb(n,k):
    return g1[n] - g1[k] - g1[n-k]

ans = 0
for x in range(1,f+1):
    ans += sub(x)
print(ans)
0