結果

問題 No.2867 NOT FOUND 404 Again
コンテスト
ユーザー 寝癖
提出日時 2024-07-08 12:56:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,896 ms / 3,000 ms
+ 117µs
コード長 1,008 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,022 ms
コンパイル使用メモリ 335,024 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2026-08-24 18:22:37
合計ジャッジ時間 36,388 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
    string N;
    cin >> N;

    int D = N.size();
    const int M = 100;

    int n[D];
    for (int i = 0; i < D; i++) n[i] = N[i]-'0';

    mint now[2][M];
    memset(now, 0, sizeof(now));
    now[0][0] = 1;

    for (int i = 0; i < D; i++) {
        mint nxt[2][M];
        memset(nxt, 0, sizeof(nxt));
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j < M; j++) {
                if (now[smaller][j].val() == 0) continue;
                for (int x = 0; x <= (smaller ? 9 : n[i]); x++) {
                    if (j*10+x == 404) continue;
                    nxt[smaller || x < n[i]][(j*10+x)%M] += now[smaller][j];
                }
            }
        }
        memcpy(now, nxt, sizeof(now));
    }

    mint ans = -1;
    for (auto x : now[0]) ans += x;
    for (auto x : now[1]) ans += x;
    cout << ans.val() << endl;
}
0