結果

問題 No.1832 NAND Reversible
ユーザー titiatitia
提出日時 2022-02-09 00:01:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 23,900 KB
最終ジャッジ日時 2023-09-06 00:48:38
合計ジャッジ時間 5,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
23,884 KB
testcase_01 AC 122 ms
23,780 KB
testcase_02 AC 128 ms
23,836 KB
testcase_03 AC 204 ms
23,656 KB
testcase_04 AC 127 ms
23,844 KB
testcase_05 AC 127 ms
23,772 KB
testcase_06 AC 127 ms
23,836 KB
testcase_07 AC 193 ms
23,844 KB
testcase_08 AC 195 ms
23,836 KB
testcase_09 AC 127 ms
23,792 KB
testcase_10 AC 130 ms
23,856 KB
testcase_11 AC 127 ms
23,656 KB
testcase_12 AC 124 ms
23,776 KB
testcase_13 AC 123 ms
23,852 KB
testcase_14 AC 125 ms
23,692 KB
testcase_15 AC 138 ms
23,744 KB
testcase_16 AC 151 ms
23,760 KB
testcase_17 AC 189 ms
23,708 KB
testcase_18 AC 124 ms
23,900 KB
testcase_19 AC 132 ms
23,848 KB
testcase_20 AC 123 ms
23,836 KB
testcase_21 AC 196 ms
23,840 KB
testcase_22 AC 196 ms
23,852 KB
testcase_23 AC 122 ms
23,736 KB
testcase_24 AC 125 ms
23,696 KB
testcase_25 AC 165 ms
23,760 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 K==0 or K==N:
    print(1)
    exit()

if K==1:
    if N%2==0:
        print(2)
    else:
        print(N-2)
    exit()

ANS=0

for a in range(0,N-K+1,2):
    ANS+=Combi(N-2-a,K-2)*(a+1)
    ANS%=mod
    #print(a,ANS)

print(ANS)



0