結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー ああいいああいい
提出日時 2022-11-29 12:52:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-04-16 08:25:42
合計ジャッジ時間 4,047 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
65,168 KB
testcase_01 AC 58 ms
65,732 KB
testcase_02 AC 59 ms
64,180 KB
testcase_03 AC 191 ms
76,176 KB
testcase_04 AC 57 ms
64,192 KB
testcase_05 AC 61 ms
65,684 KB
testcase_06 AC 58 ms
65,520 KB
testcase_07 AC 253 ms
76,400 KB
testcase_08 AC 161 ms
76,288 KB
testcase_09 AC 248 ms
76,160 KB
testcase_10 AC 246 ms
76,332 KB
testcase_11 AC 224 ms
76,416 KB
testcase_12 AC 216 ms
76,416 KB
testcase_13 AC 63 ms
67,200 KB
testcase_14 AC 169 ms
76,160 KB
testcase_15 AC 158 ms
76,032 KB
testcase_16 AC 72 ms
71,424 KB
testcase_17 AC 154 ms
75,904 KB
testcase_18 AC 157 ms
76,324 KB
testcase_19 AC 132 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

P = 998244353
ans = 0

inf = 1000
dp = [[0] * (inf + 1) for _ in range(3)]
dp[0][0] = 1
for _ in range(N):
    nx = [[0] * (inf + 1) for _ in range(3)]
    for i in range(inf + 1):
        nx[0][i] += dp[0][i] * 25
        nx[1][i] += dp[1][i] * 25 + dp[0][i]
        nx[2][i] += dp[2][i] * 25 + dp[1][i]
        if i < inf:
            nx[0][i + 1] += dp[2][i]
    for i in range(inf + 1):
        for j in range(3):
            nx[j][i] %= P
    dp = nx
ans = 0
for i in range(inf + 1):
    for j in range(3):
        ans += dp[j][i] * i
        ans %= P
print(ans)
0