結果
問題 |
No.3242 Count 8 Included Numbers (Hard)
|
ユーザー |
![]() |
提出日時 | 2025-08-22 21:58:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 100,460 KB |
実行使用メモリ | 11,300 KB |
最終ジャッジ日時 | 2025-08-22 21:58:03 |
合計ジャッジ時間 | 2,685 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#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; }