結果

問題 No.2511 Mountain Sequence
ユーザー titiatitia
提出日時 2023-11-19 03:19:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,205 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 165,560 KB
最終ジャッジ日時 2023-11-19 03:19:28
合計ジャッジ時間 18,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
146,608 KB
testcase_01 AC 110 ms
146,608 KB
testcase_02 AC 510 ms
159,016 KB
testcase_03 AC 162 ms
150,692 KB
testcase_04 AC 279 ms
161,356 KB
testcase_05 AC 283 ms
164,512 KB
testcase_06 AC 477 ms
159,016 KB
testcase_07 AC 459 ms
161,696 KB
testcase_08 AC 198 ms
162,188 KB
testcase_09 AC 146 ms
151,452 KB
testcase_10 AC 489 ms
161,712 KB
testcase_11 AC 622 ms
162,732 KB
testcase_12 AC 107 ms
146,608 KB
testcase_13 AC 598 ms
161,624 KB
testcase_14 AC 602 ms
163,724 KB
testcase_15 AC 666 ms
162,636 KB
testcase_16 AC 670 ms
160,028 KB
testcase_17 AC 598 ms
165,560 KB
testcase_18 AC 529 ms
161,720 KB
testcase_19 AC 552 ms
161,928 KB
testcase_20 AC 518 ms
162,224 KB
testcase_21 AC 600 ms
165,304 KB
testcase_22 AC 550 ms
161,680 KB
testcase_23 AC 318 ms
158,348 KB
testcase_24 AC 369 ms
158,352 KB
testcase_25 AC 691 ms
158,348 KB
testcase_26 AC 260 ms
158,352 KB
testcase_27 AC 484 ms
158,352 KB
testcase_28 WA -
testcase_29 AC 526 ms
162,248 KB
testcase_30 AC 542 ms
162,184 KB
testcase_31 AC 532 ms
162,208 KB
testcase_32 AC 583 ms
161,624 KB
testcase_33 AC 614 ms
164,424 KB
testcase_34 AC 553 ms
161,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=998244353

FACT=[1]
for i in range(1,3*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(3*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

N,M=map(int,input().split())
ANS=0

"""
for x in range(1,M):
    for j in range(N+1):
        ANS+=Combi(x,j)*Combi(x,N-1-j)

    #print(ANS)

print(ANS%mod)
"""

F2=[1,1]

for i in range(2,6*10**5+1):
    F2.append(F2[-2]*i%mod)

def calc(x,y):
    if y==x*2+1:
        return 1
    if x-y//2>=0:
        A1=FACT[x]*pow(FACT[x-y//2],mod-2,mod)
    else:
        A1=0

    if 2*x-1-(y-1)//2*2>=0:
        A2=F2[2*x-1]*pow(F2[2*x-1-(y-1)//2*2],mod-2,mod)
    else:
        A2=0

    C1=FACT[(y-1)//2]
    C2=F2[y//2*2-1]

    #print(A1,A2,C1,C2)

    if y%2==0:
        A1*=2

    return A1*A2*pow(C1*C2,mod-2,mod)%mod

for x in range(1,M):
    ANS+=calc(x,N)

    #if calc(x,N)>0:
    #    print(x,calc(x,N))

    #X=0

    #for j in range(N+1):
    #    X+=Combi(x,j)*Combi(x,N-1-j)

    #print((x,N),calc(x,N),X)


print(ANS%mod)
    
0