結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー googol_S0googol_S0
提出日時 2022-11-25 21:20:50
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 426 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 76,200 KB
最終ジャッジ日時 2024-04-10 02:28:31
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
68,056 KB
testcase_01 AC 57 ms
66,256 KB
testcase_02 AC 55 ms
67,440 KB
testcase_03 AC 52 ms
66,512 KB
testcase_04 AC 51 ms
66,696 KB
testcase_05 AC 50 ms
67,076 KB
testcase_06 AC 50 ms
66,848 KB
testcase_07 AC 52 ms
66,296 KB
testcase_08 AC 52 ms
67,168 KB
testcase_09 AC 50 ms
66,488 KB
testcase_10 AC 49 ms
66,424 KB
testcase_11 AC 53 ms
66,468 KB
testcase_12 AC 53 ms
67,672 KB
testcase_13 AC 53 ms
67,064 KB
testcase_14 AC 53 ms
66,452 KB
testcase_15 AC 52 ms
67,564 KB
testcase_16 AC 52 ms
67,180 KB
testcase_17 AC 52 ms
67,772 KB
testcase_18 AC 54 ms
68,052 KB
testcase_19 AC 54 ms
67,648 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 #

mod=998244353
def cmb(n,r):
  if r<0 or r>n:
    return 0
  return ((g1[n]*g2[r]%mod)*g2[n-r])%mod
 
N=300000
g1=[1]*(N+3)
for i in range(2,N+3):
  g1[i]=g1[i-1]*i%mod
g2=[0]*len(g1)
g2[-1]=pow(g1[-1],mod-2,mod)
for i in range(N+1,-1,-1):
  g2[i]=g2[i+1]*(i+1)%mod
inv=[0]*(N+3)
for i in range(1,N+3):
  inv[i]=g2[i]*g1[i-1]%mod

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