結果

問題 No.2383 Naphthol
ユーザー titiatitia
提出日時 2023-07-20 01:04:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 881 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 26,040 KB
最終ジャッジ日時 2023-10-20 03:01:11
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
25,980 KB
testcase_01 AC 156 ms
25,980 KB
testcase_02 AC 157 ms
25,980 KB
testcase_03 AC 157 ms
25,980 KB
testcase_04 AC 158 ms
25,980 KB
testcase_05 AC 158 ms
25,980 KB
testcase_06 AC 155 ms
25,980 KB
testcase_07 AC 158 ms
25,980 KB
testcase_08 AC 162 ms
25,980 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 156 ms
25,980 KB
testcase_13 AC 156 ms
25,980 KB
testcase_14 AC 155 ms
25,980 KB
testcase_15 AC 156 ms
25,980 KB
testcase_16 AC 154 ms
25,980 KB
testcase_17 AC 155 ms
25,980 KB
testcase_18 AC 155 ms
25,980 KB
testcase_19 AC 156 ms
25,980 KB
testcase_20 AC 155 ms
25,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())

mod=998244353

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

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*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

if N==1:
    ANS=[1,1,3,3,3,1,1]
    print(ANS[K])
    exit()

ANS=Combi(2*N+4,K)

# 回転
if K%2==0:
    ANS+=Combi(N+2,K//2)

# 横反転
if N%2==0:
    if K%2==0:
        ANS+=Combi(N+2,K//2)
else:
    # N+3のうち 1:1のものが二つ、他は1:2

    # 0個
    if K%2==0:
        ANS+=Combi(N+1,K//2)

    # 1個
    if K%2==1:
        ANS+=Combi(N+1,(K-1)//2)*2

    # 2個
    if K%2==0:
        ANS+=Combi(N+1,(K-2)//2)
 
# 縦反転
if K%2==0:
    ANS+=Combi(N+2,K//2)

print((ANS*pow(4,mod-2,mod)%mod)%mod)
0