問題一覧 > 通常問題

No.2867 NOT FOUND 404 Again

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 85
作問者 : yuusaan / テスター : 寝癖 👑 seekworser
お気に入りにしたユーザー ProblemId : 11085 / 自分の提出
問題文最終更新日: 2024-09-25 11:20:01
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 443 (順位表) の他の問題:

Story

Yu-san is a researcher studying parallel worlds, but today he is taking a day off and chatting leisurely with you, his assistant.

"All right, here's a problem. Among the positive integers up to $10$ oku (one billion), how many do not contain the number I hate, that is, 404?"

You found that tedious, so you tried to have a machine compute it.

While you were writing the code, Yu-san caught you. Then he said this:

"Hey, that's not allowed.... Ah, no, actually, you may use it. But if you're using a machine, $10$ oku (one billion) is too small, right? You can surely handle about this much."

Problem Statement

Find the number of positive integers less than or equal to $N$ that satisfy the following condition.

  • When its decimal representation is interpreted as a string, no substring of $3$ consecutive characters is 404

Since the answer can be very large, output it modulo $998244353$.

Also, note that the given value of $N$ can be extremely large.

Input

$N$

Constraints

  • $1\leq N \leq$ $10^{1000000}$ $=$ $10^{10^6}$
  • All inputs are integers

Output

Output the answer on one line, followed by a newline.

Sample

Sample 1
Input
1000
Output
999

All positive integers from $1$ to $1000$ except $404$ satisfy the condition, so output $999$.

Sample 2
Input
98765432109876543210
Output
848152577

Note that you must output the value modulo $998244353$, and that the given $N$ may not fit in a $64$-bit integer type.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。