結果

問題 No.1832 NAND Reversible
ユーザー tamatotamato
提出日時 2022-02-04 22:30:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 960 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 87,552 KB
実行使用メモリ 81,364 KB
最終ジャッジ日時 2023-09-02 05:07:28
合計ジャッジ時間 4,510 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 89 ms
80,740 KB
testcase_02 AC 89 ms
80,876 KB
testcase_03 AC 93 ms
81,088 KB
testcase_04 AC 87 ms
81,084 KB
testcase_05 WA -
testcase_06 AC 90 ms
81,028 KB
testcase_07 AC 92 ms
80,872 KB
testcase_08 AC 95 ms
81,364 KB
testcase_09 AC 89 ms
80,988 KB
testcase_10 AC 90 ms
81,256 KB
testcase_11 WA -
testcase_12 AC 88 ms
80,816 KB
testcase_13 AC 88 ms
80,824 KB
testcase_14 AC 90 ms
80,904 KB
testcase_15 AC 94 ms
81,248 KB
testcase_16 AC 93 ms
81,112 KB
testcase_17 AC 93 ms
81,132 KB
testcase_18 AC 92 ms
81,028 KB
testcase_19 AC 91 ms
81,004 KB
testcase_20 AC 89 ms
81,092 KB
testcase_21 AC 94 ms
81,176 KB
testcase_22 AC 93 ms
81,076 KB
testcase_23 AC 88 ms
80,844 KB
testcase_24 AC 89 ms
80,772 KB
testcase_25 AC 92 ms
80,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    nmax = 2 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

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

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

    ans = 0
    for k in range(0, N - K + 1, 2):
        tmp = (comb(N - k - 2, K - 2) * (k + 1))%mod
        ans = (ans + tmp)%mod
        #print(ans)
    print(ans)


if __name__ == '__main__':
    main()
0