結果

問題 No.2188 整数列コイントスゲーム
ユーザー tassei903tassei903
提出日時 2023-01-13 22:50:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 90,012 KB
最終ジャッジ日時 2023-08-26 04:35:55
合計ジャッジ時間 11,873 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
89,964 KB
testcase_01 AC 222 ms
89,880 KB
testcase_02 AC 219 ms
89,964 KB
testcase_03 AC 218 ms
89,884 KB
testcase_04 AC 218 ms
90,004 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 222 ms
89,948 KB
testcase_08 AC 71 ms
71,228 KB
testcase_09 AC 72 ms
71,284 KB
testcase_10 AC 219 ms
90,008 KB
testcase_11 AC 217 ms
90,012 KB
testcase_12 AC 217 ms
89,952 KB
testcase_13 AC 217 ms
89,736 KB
testcase_14 AC 223 ms
89,808 KB
testcase_15 WA -
testcase_16 AC 70 ms
71,360 KB
testcase_17 AC 73 ms
71,468 KB
testcase_18 AC 70 ms
71,296 KB
testcase_19 AC 69 ms
71,216 KB
testcase_20 AC 223 ms
89,684 KB
testcase_21 AC 225 ms
89,888 KB
testcase_22 AC 224 ms
89,948 KB
testcase_23 AC 230 ms
89,844 KB
testcase_24 AC 225 ms
89,804 KB
testcase_25 AC 71 ms
71,216 KB
testcase_26 AC 221 ms
89,684 KB
testcase_27 AC 224 ms
89,872 KB
testcase_28 AC 227 ms
89,944 KB
testcase_29 AC 224 ms
89,808 KB
testcase_30 AC 223 ms
89,980 KB
testcase_31 AC 72 ms
71,160 KB
testcase_32 AC 223 ms
89,876 KB
testcase_33 AC 225 ms
89,700 KB
testcase_34 AC 230 ms
89,924 KB
testcase_35 AC 71 ms
71,220 KB
testcase_36 AC 227 ms
89,972 KB
testcase_37 AC 225 ms
89,888 KB
testcase_38 AC 227 ms
89,960 KB
testcase_39 AC 70 ms
71,360 KB
testcase_40 AC 226 ms
89,944 KB
testcase_41 AC 225 ms
89,840 KB
testcase_42 AC 223 ms
89,760 KB
testcase_43 AC 226 ms
89,692 KB
testcase_44 AC 229 ms
89,796 KB
testcase_45 AC 224 ms
89,760 KB
testcase_46 AC 69 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
fact = [1]
for i in range(15):
    fact.append((i+1)*fact[-1])
k = 17
b = [[0 for j in range(k)]for i in range(k+1)]
b[0][0] = 1
for i in range(k):
    for j in range(k):
        if j:
            b[i+1][j] += b[i][j-1]
        b[i+1][j] += b[i][j] * (-i)


n = ni()
m = ni()
if n == 0:
    print("NaN")
    exit()
if m > n:
    print(0)
    exit()
from fractions import Fraction
a = [Fraction(0)] * (n+1)
a[-1] = Fraction(1)
ans = []
for i in range(n, 0, -1):
    x = a[i] * fact[i]
    ans.append(a[i]*fact[i])
    for j in range(n+1):
        a[j] -= x * b[i][j] / fact[i]
    #print(a)
ans = [0] + ans[::-1]
print(int(ans[m]))
0