結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー 👑 H20H20
提出日時 2022-11-25 22:05:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 263 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 75,408 KB
最終ジャッジ日時 2024-04-10 03:14:13
合計ジャッジ時間 3,290 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,312 KB
testcase_01 AC 39 ms
52,220 KB
testcase_02 AC 39 ms
52,176 KB
testcase_03 AC 42 ms
52,544 KB
testcase_04 AC 40 ms
52,400 KB
testcase_05 AC 39 ms
53,700 KB
testcase_06 AC 38 ms
53,316 KB
testcase_07 AC 40 ms
52,396 KB
testcase_08 AC 40 ms
52,368 KB
testcase_09 AC 40 ms
53,140 KB
testcase_10 AC 43 ms
52,376 KB
testcase_11 AC 39 ms
52,056 KB
testcase_12 AC 40 ms
52,876 KB
testcase_13 AC 37 ms
52,708 KB
testcase_14 AC 37 ms
52,940 KB
testcase_15 AC 38 ms
53,368 KB
testcase_16 AC 38 ms
54,376 KB
testcase_17 AC 47 ms
61,416 KB
testcase_18 AC 54 ms
61,744 KB
testcase_19 AC 51 ms
61,488 KB
testcase_20 AC 36 ms
52,812 KB
testcase_21 AC 56 ms
63,372 KB
testcase_22 AC 36 ms
52,960 KB
testcase_23 AC 54 ms
61,884 KB
testcase_24 AC 36 ms
52,404 KB
testcase_25 AC 54 ms
62,224 KB
testcase_26 AC 36 ms
52,092 KB
testcase_27 AC 156 ms
75,408 KB
testcase_28 AC 37 ms
52,368 KB
testcase_29 AC 155 ms
75,388 KB
testcase_30 AC 37 ms
52,184 KB
testcase_31 AC 37 ms
52,220 KB
testcase_32 AC 36 ms
52,212 KB
testcase_33 AC 36 ms
52,344 KB
testcase_34 AC 36 ms
52,880 KB
testcase_35 AC 36 ms
53,008 KB
testcase_36 AC 36 ms
52,160 KB
testcase_37 AC 37 ms
52,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#逆元、割り算する場合に使用
def modinv(a):
    return pow(a, mod-2, mod)

N = int(input())
M = int(input())
mod = 998244353
ans = pow(2,N,mod)-1
temp = N
for i in range(1,M):
    ans = (ans-temp)%mod
    temp = (temp*(N-i)*modinv(i+1))%mod
print(ans)
0