結果

問題 No.2188 整数列コイントスゲーム
ユーザー tassei903tassei903
提出日時 2023-01-13 22:45:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 947 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 90,112 KB
最終ジャッジ日時 2023-08-26 04:30:45
合計ジャッジ時間 10,497 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
89,956 KB
testcase_01 AC 195 ms
90,068 KB
testcase_02 AC 200 ms
89,792 KB
testcase_03 AC 199 ms
89,864 KB
testcase_04 AC 206 ms
89,964 KB
testcase_05 WA -
testcase_06 AC 67 ms
71,092 KB
testcase_07 AC 199 ms
89,880 KB
testcase_08 AC 65 ms
71,292 KB
testcase_09 AC 64 ms
71,436 KB
testcase_10 AC 196 ms
89,824 KB
testcase_11 AC 191 ms
89,784 KB
testcase_12 AC 191 ms
90,112 KB
testcase_13 AC 195 ms
90,036 KB
testcase_14 AC 206 ms
90,032 KB
testcase_15 AC 66 ms
71,100 KB
testcase_16 AC 65 ms
71,276 KB
testcase_17 AC 66 ms
71,240 KB
testcase_18 AC 66 ms
71,312 KB
testcase_19 AC 66 ms
71,440 KB
testcase_20 AC 205 ms
89,860 KB
testcase_21 AC 206 ms
89,860 KB
testcase_22 AC 203 ms
90,076 KB
testcase_23 AC 201 ms
89,784 KB
testcase_24 AC 199 ms
90,020 KB
testcase_25 AC 70 ms
71,412 KB
testcase_26 AC 206 ms
89,948 KB
testcase_27 AC 203 ms
90,052 KB
testcase_28 AC 201 ms
89,992 KB
testcase_29 AC 201 ms
89,844 KB
testcase_30 AC 206 ms
90,036 KB
testcase_31 AC 66 ms
71,292 KB
testcase_32 AC 205 ms
89,940 KB
testcase_33 AC 207 ms
89,928 KB
testcase_34 AC 203 ms
90,008 KB
testcase_35 AC 66 ms
71,416 KB
testcase_36 AC 203 ms
89,948 KB
testcase_37 AC 205 ms
89,872 KB
testcase_38 AC 204 ms
89,868 KB
testcase_39 AC 64 ms
71,488 KB
testcase_40 AC 196 ms
90,008 KB
testcase_41 AC 194 ms
89,876 KB
testcase_42 AC 199 ms
90,076 KB
testcase_43 AC 194 ms
90,108 KB
testcase_44 AC 209 ms
89,788 KB
testcase_45 AC 203 ms
89,836 KB
testcase_46 AC 64 ms
71,440 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 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