結果

問題 No.2511 Mountain Sequence
ユーザー ゼット
提出日時 2023-10-23 19:11:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 76,340 KB
最終ジャッジ日時 2024-09-22 12:57:14
合計ジャッジ時間 7,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
K=2*(M+N)
mod=998244353
u=[1]*(K+1)
for i in range(1,K+1):
  u[i]=u[i-1]*i
  u[i]%=mod
u2=[1]*(K+1)
for i in range(1,K+1):
  ans=1
  w=u[i]
  n=mod-2
  while n>0:
    if n&1:
      ans*=w
      ans%=mod
    w**=2
    w%=mod
    n//=2
  u2[i]=ans
def ncm(x,y):
  if y>x:
    return 0
  ans=u[x]
  ans*=u2[y]
  ans%=mod
  ans*=u2[x-y]
  ans%=mod
  return ans
result=0
for k in range(1,M+1):
  result+=ncm(2*k-2,N-1)
  result%=mod
print(result)
0