結果
問題 |
No.3240 Count 8 Included Numbers (Easy)
|
ユーザー |
![]() |
提出日時 | 2025-08-22 21:58:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 825 ms |
コンパイル使用メモリ | 100,560 KB |
実行使用メモリ | 10,280 KB |
最終ジャッジ日時 | 2025-08-22 21:58:16 |
合計ジャッジ時間 | 1,821 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { const int mod = 998244353; string s; cin >> s; const int siz = 900000; long long ans = 0; for (auto c : s) ans = (ans * 10 + c - '0') % mod; ans = (ans + 1) % mod; vector<long long> p9(siz); p9[0] = 1; for (int i = 0; i < siz - 1; ++i) p9[i + 1] = p9[i] * 9 % mod; int flag = 1, k = s.size() - 1; for (char c : s) { if (c == '8') { flag = 0; ans = (ans - p9[k] * 8) % mod; break; } else { ans = (ans - p9[k] * min(c - '0', 8)) % mod; } --k; } ans = (ans + mod - flag) % mod; cout << ans << endl; }