結果

問題 No.2867 NOT FOUND 404 Again
ユーザー ShirotsumeShirotsume
提出日時 2024-08-30 22:36:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,313 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,828 KB
実行使用メモリ 213,456 KB
最終ジャッジ日時 2024-08-30 22:36:11
合計ジャッジ時間 6,364 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,984 KB
testcase_01 AC 47 ms
57,272 KB
testcase_02 AC 47 ms
56,572 KB
testcase_03 WA -
testcase_04 AC 248 ms
167,740 KB
testcase_05 WA -
testcase_06 AC 248 ms
167,756 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 250 ms
167,868 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 246 ms
167,756 KB
testcase_17 WA -
testcase_18 AC 330 ms
213,456 KB
testcase_19 AC 436 ms
209,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
def debug(*x):print('debug:',*x, file=sys.stderr)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

N = input()
n = len(N)
dp = [[0] * 3 for _ in range(n + 1)]

dp[0][0] = 1

for i in range(n):
    dp[i + 1][0] += dp[i][0] * 9
    dp[i + 1][0] %= mod
    dp[i + 1][1] += dp[i][0]
    dp[i + 1][1] %= mod
    dp[i + 1][1] += dp[i][1]
    dp[i + 1][1] %= mod
    dp[i + 1][2] += dp[i][1]
    dp[i + 1][2] %= mod
    dp[i + 1][0] += dp[i][1] * 8
    dp[i + 1][0] %= mod
    dp[i + 1][0] += dp[i][2] * 9
    dp[i + 1][0] %= mod
    

A = [-1, -1]
ans = 0

for i in range(n):
    unbef = A[-2]
    bef = A[-1]
    f = True
    for to in range(0, int(N[i])):
        if to == 4:
            ans += dp[n - i - 1][0] + dp[n - i - 1][1]
            ans %= mod
        elif bef == 4 and to == 0:
            ans += dp[n - i - 1][0] + dp[n - i - 1][2]
            ans %= mod
        else:
            ans += dp[n - i - 1][0] + dp[n - i - 1][1] + dp[n - i - 1][2]
            ans %= mod
    A.append(int(N[i]))
    if A[-3] == 4 and A[-2] == 0 and A[-1] == 4:
        break
if '404' in N:
    ans -= 1
    ans %= mod
print(ans)
0