結果

問題 No.2058 Binary String
ユーザー 👑 tamatotamato
提出日時 2022-08-26 22:05:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 66,252 KB
最終ジャッジ日時 2024-04-22 00:10:14
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
63,460 KB
testcase_01 AC 51 ms
63,664 KB
testcase_02 AC 60 ms
65,172 KB
testcase_03 AC 46 ms
62,864 KB
testcase_04 AC 44 ms
64,032 KB
testcase_05 AC 50 ms
63,412 KB
testcase_06 AC 53 ms
65,556 KB
testcase_07 AC 112 ms
65,908 KB
testcase_08 AC 60 ms
65,588 KB
testcase_09 AC 119 ms
66,252 KB
testcase_10 AC 74 ms
65,320 KB
testcase_11 AC 63 ms
65,892 KB
testcase_12 AC 84 ms
64,792 KB
testcase_13 AC 76 ms
64,928 KB
testcase_14 AC 70 ms
65,048 KB
testcase_15 AC 68 ms
66,056 KB
testcase_16 AC 67 ms
65,056 KB
testcase_17 AC 77 ms
64,924 KB
testcase_18 AC 52 ms
65,880 KB
testcase_19 AC 120 ms
65,500 KB
testcase_20 AC 111 ms
64,988 KB
testcase_21 AC 122 ms
65,736 KB
testcase_22 AC 117 ms
65,408 KB
testcase_23 AC 127 ms
66,028 KB
testcase_24 AC 118 ms
65,244 KB
testcase_25 AC 128 ms
66,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


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())

    ans = 0
    for i in range(1, N):
        c = comb(N - 1, i)
        ans = (ans + (c * pow(i, K, mod)) % mod) % mod
    print(ans)


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