結果

問題 No.3242 Count 8 Included Numbers (Hard)
ユーザー cologne
提出日時 2025-09-02 18:04:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,177 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 3,330 ms
コンパイル使用メモリ 277,484 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-02 18:04:29
合計ジャッジ時間 11,140 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using Mint = atcoder::modint998244353;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string N;
    cin >> N;
    bool exist_8 = false;
    Mint ans = 0;
    for (int i = 0; i < (int)N.size(); i++)
    {
        int d = N[i] - '0';
        for (int j = 0; j < d; j++)
        {
            ans += Mint(10).pow((int)N.size() - 1 - i);
            if (!(exist_8 || j == 8))
                ans -= Mint(9).pow((int)N.size() - 1 - i);
        }
        if (d == 8)
            exist_8 = true;
    }
    if (exist_8)
        ans += 1;
    cout << ans.val() << endl;
}
0