結果

問題 No.2188 整数列コイントスゲーム
ユーザー tassei903tassei903
提出日時 2023-01-13 22:52:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 90,172 KB
最終ジャッジ日時 2023-08-26 04:38:45
合計ジャッジ時間 11,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
90,000 KB
testcase_01 AC 213 ms
89,984 KB
testcase_02 AC 216 ms
89,972 KB
testcase_03 AC 216 ms
89,996 KB
testcase_04 AC 217 ms
89,888 KB
testcase_05 AC 70 ms
71,400 KB
testcase_06 AC 69 ms
71,328 KB
testcase_07 AC 213 ms
89,880 KB
testcase_08 AC 70 ms
71,408 KB
testcase_09 AC 69 ms
71,352 KB
testcase_10 AC 215 ms
89,888 KB
testcase_11 AC 211 ms
90,008 KB
testcase_12 AC 212 ms
89,868 KB
testcase_13 AC 215 ms
89,924 KB
testcase_14 AC 219 ms
89,892 KB
testcase_15 AC 70 ms
71,128 KB
testcase_16 AC 69 ms
71,444 KB
testcase_17 AC 70 ms
71,352 KB
testcase_18 AC 68 ms
71,116 KB
testcase_19 AC 70 ms
71,456 KB
testcase_20 AC 216 ms
90,148 KB
testcase_21 AC 215 ms
89,824 KB
testcase_22 AC 216 ms
89,984 KB
testcase_23 AC 216 ms
90,056 KB
testcase_24 AC 222 ms
90,008 KB
testcase_25 AC 71 ms
71,492 KB
testcase_26 AC 217 ms
89,944 KB
testcase_27 AC 218 ms
89,928 KB
testcase_28 AC 219 ms
89,928 KB
testcase_29 AC 219 ms
89,888 KB
testcase_30 AC 218 ms
90,040 KB
testcase_31 AC 68 ms
71,492 KB
testcase_32 AC 218 ms
90,172 KB
testcase_33 AC 218 ms
89,776 KB
testcase_34 AC 218 ms
89,932 KB
testcase_35 AC 69 ms
71,244 KB
testcase_36 AC 222 ms
90,008 KB
testcase_37 AC 221 ms
89,880 KB
testcase_38 AC 221 ms
90,040 KB
testcase_39 AC 70 ms
71,068 KB
testcase_40 AC 222 ms
90,084 KB
testcase_41 AC 225 ms
90,008 KB
testcase_42 AC 228 ms
89,772 KB
testcase_43 AC 222 ms
89,864 KB
testcase_44 AC 221 ms
89,872 KB
testcase_45 AC 222 ms
90,076 KB
testcase_46 AC 70 ms
71,328 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:
    if m == 0:
        print(1)
    else:
        print(0)
    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