結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー 👑 tamatotamato
提出日時 2022-11-25 21:29:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 62,156 KB
最終ジャッジ日時 2024-04-10 02:40:47
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,724 KB
testcase_01 AC 41 ms
53,704 KB
testcase_02 AC 38 ms
52,616 KB
testcase_03 AC 48 ms
60,664 KB
testcase_04 AC 36 ms
53,632 KB
testcase_05 AC 38 ms
52,276 KB
testcase_06 AC 37 ms
52,836 KB
testcase_07 AC 44 ms
61,756 KB
testcase_08 AC 43 ms
60,596 KB
testcase_09 AC 45 ms
60,832 KB
testcase_10 AC 44 ms
62,156 KB
testcase_11 AC 45 ms
60,804 KB
testcase_12 AC 45 ms
60,548 KB
testcase_13 AC 38 ms
52,132 KB
testcase_14 AC 45 ms
61,816 KB
testcase_15 AC 44 ms
60,452 KB
testcase_16 AC 38 ms
52,688 KB
testcase_17 AC 45 ms
61,300 KB
testcase_18 AC 45 ms
60,308 KB
testcase_19 AC 45 ms
61,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


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

    N = int(input())

    dp = [0] * 3
    dp[0] = 1
    ans = 0
    for j in range(N):
        dp_new = [0] * 3
        for i in range(3):
            dp_new[i] = (dp_new[i] + (dp[i] * 25) % mod) % mod
            dp_new[(i + 1) % 3] = (dp_new[(i + 1) % 3] + dp[i]) % mod
            if i == 2:
                ans = (ans + (dp[i] * pow(26, N - j - 1, mod)) % mod) % mod
        dp = dp_new
    print(ans)


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