結果
| 問題 | No.2867 NOT FOUND 404 Again | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-08-13 10:46:39 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2,119 ms / 3,000 ms | 
| コード長 | 556 bytes | 
| コンパイル時間 | 306 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 131,772 KB | 
| 最終ジャッジ日時 | 2025-08-13 10:47:15 | 
| 合計ジャッジ時間 | 31,139 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
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)
            
            
            
        