結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー shobonvipshobonvip
提出日時 2022-11-25 21:35:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 63,108 KB
最終ジャッジ日時 2024-04-10 02:47:25
合計ジャッジ時間 1,793 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,688 KB
testcase_01 AC 40 ms
52,708 KB
testcase_02 AC 38 ms
53,424 KB
testcase_03 AC 45 ms
62,164 KB
testcase_04 AC 35 ms
52,756 KB
testcase_05 AC 37 ms
52,608 KB
testcase_06 AC 37 ms
53,248 KB
testcase_07 AC 47 ms
62,588 KB
testcase_08 AC 46 ms
62,372 KB
testcase_09 AC 46 ms
62,308 KB
testcase_10 AC 47 ms
62,380 KB
testcase_11 AC 47 ms
61,884 KB
testcase_12 AC 45 ms
62,472 KB
testcase_13 AC 35 ms
52,756 KB
testcase_14 AC 46 ms
61,692 KB
testcase_15 AC 46 ms
61,372 KB
testcase_16 AC 37 ms
52,680 KB
testcase_17 AC 47 ms
63,108 KB
testcase_18 AC 46 ms
61,784 KB
testcase_19 AC 39 ms
54,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# dp[i][j] : i番目まで見て
# j = 0 ... xxx
# j = 1 ... xxc
# j = 2 ... xco
# j = 3 ... con

mod = 998244353
n = int(input())
dp = [[0] * 4 for i in range(n+1)]
dp[0][0] = 1
ans = 0
for i in range(n):
	dp[i+1][1] = dp[i][0] + dp[i][1] * 25 + dp[i][3]
	dp[i+1][2] = dp[i][1] + dp[i][2] * 25
	dp[i+1][3] = dp[i][2]
	dp[i+1][0] = dp[i][0] * 25 + dp[i][3] * 25
	dp[i+1][1] %= mod
	dp[i+1][2] %= mod
	dp[i+1][0] %= mod
	ans += dp[i+1][3] * pow(26, n-i-1, mod)
	ans %= mod
print(ans)
#print(*dp)
0