結果

問題 No.2867 NOT FOUND 404 Again
ユーザー OhnoHirokiOhnoHiroki
提出日時 2024-08-30 22:08:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,924 KB
最終ジャッジ日時 2024-08-30 22:08:56
合計ジャッジ時間 43,131 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1,357 ms
12,668 KB
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
P = 998244353

dp_eq = [1, 0, 0] #0文字一致, 1文字一致, 2文字一致
dp = [0,0,0]
for n in N:
    dp = [(dp[0]*9 + dp[1]*8 + dp[2]*9) % P, (dp[0]+dp[1]) % P, dp[1]]
    for i in range(int(n)):
        if i == 0:
            dp[0] += (dp_eq[0] + dp_eq[2])
            dp[2] += dp_eq[1]
        elif i == 4:
            dp[1] += dp_eq[0] + dp_eq[1]
            dp[0] += dp_eq[1]
        else:
            dp[0] += 1
    if n == "0" and dp_eq[1] > 0:
        dp_eq = [0,0,1]
    elif n == "4":
        if dp_eq[2] > 0:
            dp_eq = [0,0,0]
        else:
            dp_eq = [0, 1, 0]
    else:
        dp_eq = [1,0,0]

print((sum(dp) + sum(dp_eq) - 1) % P)
0