結果

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

ソースコード

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