結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー ニックネームニックネーム
提出日時 2022-11-25 21:35:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 411 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 272,624 KB
最終ジャッジ日時 2024-04-10 02:47:38
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
17,824 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 29 ms
10,880 KB
testcase_06 AC 29 ms
10,880 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 27 ms
10,752 KB
testcase_12 AC 28 ms
10,752 KB
testcase_13 AC 28 ms
10,880 KB
testcase_14 AC 29 ms
10,752 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 30 ms
10,880 KB
testcase_17 AC 37 ms
11,392 KB
testcase_18 AC 45 ms
11,904 KB
testcase_19 AC 134 ms
20,688 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input()); m = int(input()); mod = 998244353
fact, inv, factinv = [1, 1], [0, 1], [1, 1]
for i in range(2, n+1):
    fact.append(fact[-1]*i%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append(factinv[-1]*inv[-1]%mod)
def cmb(n, r):
    if r < 0 or n < r: return 0
    return fact[n]*factinv[r]%mod*factinv[n-r]%mod
ans = pow(2, n, mod)
for i in range(m): ans = (ans-cmb(n, i))%mod
print(ans)
0