結果

問題 No.2867 NOT FOUND 404 Again
ユーザー 寝癖寝癖
提出日時 2024-07-08 12:20:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,726 ms / 3,000 ms
コード長 556 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 131,604 KB
最終ジャッジ日時 2024-08-17 23:35:59
合計ジャッジ時間 25,491 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(map(int, input()))
D = len(N)
M = 4
now = [[0] * M for _ in range(2)]
now[0][0] = 1

for i, n in enumerate(N):
    nxt = [[0] * M for _ in range(2)]
    for smaller in range(2):
        for j in range(M-1):
            for x in range(10 if smaller else n + 1):
                cond = (j == 0 and x == 4) or (j == 1 and x == 0) or (j == 2 and x == 4)
                nxt[smaller or x < n][j+1 if cond else x == 4] += now[smaller][j]
    now = [[v % 998244353 for v in row] for row in nxt]

print((sum(now[0][:3]) + sum(now[1][:3]) - 1) % 998244353)
0