結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
246,864 KB
testcase_01 AC 255 ms
246,396 KB
testcase_02 AC 252 ms
245,956 KB
testcase_03 AC 260 ms
247,308 KB
testcase_04 AC 255 ms
246,508 KB
testcase_05 AC 254 ms
246,264 KB
testcase_06 AC 250 ms
246,524 KB
testcase_07 AC 258 ms
247,420 KB
testcase_08 AC 255 ms
246,464 KB
testcase_09 AC 255 ms
247,768 KB
testcase_10 AC 255 ms
246,764 KB
testcase_11 AC 255 ms
247,272 KB
testcase_12 AC 259 ms
247,228 KB
testcase_13 AC 256 ms
247,524 KB
testcase_14 AC 255 ms
247,928 KB
testcase_15 AC 251 ms
246,208 KB
testcase_16 AC 258 ms
246,464 KB
testcase_17 AC 266 ms
247,456 KB
testcase_18 AC 266 ms
247,324 KB
testcase_19 AC 259 ms
247,796 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 #

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

if n<m:exit(print(0))
ans=pow(2,n,mod)
for i in range(m):
    ans-=cmb(n,i,mod)
    ans%=mod
print(ans)
0