結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー 👑 H20H20
提出日時 2022-11-25 21:41:58
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 593 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 81,964 KB
実行使用メモリ 550,776 KB
最終ジャッジ日時 2024-04-10 02:55:17
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
59,416 KB
testcase_01 AC 34 ms
52,880 KB
testcase_02 AC 32 ms
53,040 KB
testcase_03 AC 35 ms
53,132 KB
testcase_04 AC 33 ms
52,680 KB
testcase_05 AC 33 ms
52,660 KB
testcase_06 AC 34 ms
52,948 KB
testcase_07 AC 34 ms
51,884 KB
testcase_08 AC 34 ms
53,872 KB
testcase_09 AC 35 ms
52,948 KB
testcase_10 AC 33 ms
52,092 KB
testcase_11 AC 33 ms
52,616 KB
testcase_12 AC 34 ms
52,404 KB
testcase_13 AC 33 ms
52,316 KB
testcase_14 AC 35 ms
53,992 KB
testcase_15 AC 36 ms
53,140 KB
testcase_16 AC 37 ms
54,220 KB
testcase_17 AC 46 ms
62,776 KB
testcase_18 AC 49 ms
66,604 KB
testcase_19 AC 61 ms
80,892 KB
testcase_20 AC 833 ms
319,564 KB
testcase_21 MLE -
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 #

#コンビネーション
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


N = int(input())
M = int(input())
mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = pow(2,N,mod)
for i in range(M):
    ans = (ans-cmb(N,i,mod))%mod
print(ans)
0