結果

問題 No.2188 整数列コイントスゲーム
ユーザー KudeKude
提出日時 2023-01-13 22:43:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-12-24 18:35:15
合計ジャッジ時間 4,462 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial

s = [[0] * 20 for _ in range(20)]
s[0][0] = 1
for i in range(20):
    for j in range(20):
        if i + 1 < 20:
            s[i + 1][j] += s[i][j]
        if j + 1 < 20:
            s[i][j + 1] += s[i][j] * i

n = int(input())
m = int(input())
if n == 0:
    print(int(m == 0))
else:
    print(s[m][n - m] * factorial(m) if m <= n else 0)
0