結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー rosso01rosso01
提出日時 2022-11-25 21:38:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 80,288 KB
最終ジャッジ日時 2024-04-10 02:51:09
合計ジャッジ時間 2,832 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,808 KB
testcase_01 AC 35 ms
52,612 KB
testcase_02 AC 35 ms
53,268 KB
testcase_03 AC 35 ms
51,880 KB
testcase_04 AC 35 ms
52,872 KB
testcase_05 AC 36 ms
53,260 KB
testcase_06 AC 35 ms
53,668 KB
testcase_07 AC 36 ms
52,976 KB
testcase_08 AC 35 ms
53,748 KB
testcase_09 AC 36 ms
54,104 KB
testcase_10 AC 35 ms
52,276 KB
testcase_11 AC 36 ms
53,348 KB
testcase_12 AC 39 ms
52,884 KB
testcase_13 AC 36 ms
54,044 KB
testcase_14 AC 37 ms
53,096 KB
testcase_15 AC 37 ms
54,216 KB
testcase_16 AC 37 ms
53,176 KB
testcase_17 AC 42 ms
61,120 KB
testcase_18 AC 43 ms
61,844 KB
testcase_19 AC 43 ms
60,996 KB
testcase_20 AC 36 ms
53,200 KB
testcase_21 AC 44 ms
62,412 KB
testcase_22 AC 35 ms
52,968 KB
testcase_23 AC 44 ms
62,532 KB
testcase_24 AC 36 ms
52,192 KB
testcase_25 AC 45 ms
62,196 KB
testcase_26 AC 36 ms
52,684 KB
testcase_27 AC 61 ms
80,288 KB
testcase_28 AC 38 ms
52,008 KB
testcase_29 AC 60 ms
79,708 KB
testcase_30 AC 37 ms
52,476 KB
testcase_31 AC 36 ms
52,488 KB
testcase_32 AC 36 ms
52,636 KB
testcase_33 AC 36 ms
53,380 KB
testcase_34 AC 37 ms
53,444 KB
testcase_35 AC 37 ms
52,388 KB
testcase_36 AC 36 ms
53,432 KB
testcase_37 AC 36 ms
53,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

N=int(input())
M=int(input())

fac = [1]
for i in range(1,M+5):
  fac.append(fac[-1]*i%mod)
  
invfac = [1]*(M+5)
invfac[M+4] = pow(fac[M+4],mod-2,mod)
for i in range(M+3,0,-1):
  invfac[i] = invfac[i+1]*(i+1)%mod

ans = pow(2,N,mod)-1
if M > 1:
  num = N
  ans -= num
  ans %= mod
for i in range(2,M):
  num *= N-i+1
  num %= mod
  ans -= num * invfac[i]
  ans %= mod
  
print(ans)
0