結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー 👑 H20H20
提出日時 2022-11-25 21:36:19
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 512 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 90,636 KB
最終ジャッジ日時 2024-04-10 02:49:04
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
82,016 KB
testcase_01 AC 62 ms
81,892 KB
testcase_02 AC 62 ms
81,412 KB
testcase_03 AC 60 ms
80,836 KB
testcase_04 AC 61 ms
81,468 KB
testcase_05 AC 61 ms
81,552 KB
testcase_06 AC 62 ms
82,284 KB
testcase_07 AC 60 ms
80,876 KB
testcase_08 AC 60 ms
81,520 KB
testcase_09 AC 60 ms
80,632 KB
testcase_10 AC 60 ms
81,848 KB
testcase_11 AC 61 ms
80,540 KB
testcase_12 AC 60 ms
80,932 KB
testcase_13 AC 61 ms
81,696 KB
testcase_14 AC 61 ms
81,624 KB
testcase_15 AC 61 ms
81,176 KB
testcase_16 AC 60 ms
80,612 KB
testcase_17 AC 63 ms
82,916 KB
testcase_18 AC 64 ms
82,948 KB
testcase_19 AC 68 ms
84,084 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二項係数

mod = 998244353
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]


def init(n):
    for i in range(2, n + 1):
        fac.append(fac[-1] * i % mod)
        inv.append(-inv[mod % i] * (mod // i) % mod)
        finv.append(finv[-1] * inv[-1] % mod)


def com(n, k, mod):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

init(10**5+10)
N = int(input())
M = int(input())
ans = pow(2,N,mod)
for i in range(M):
    ans = (ans-com(N,i,mod))%mod
print(ans)
0