結果
問題 |
No.3242 Count 8 Included Numbers (Hard)
|
ユーザー |
|
提出日時 | 2025-10-13 16:38:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 8,838 ms |
コンパイル使用メモリ | 251,092 KB |
実行使用メモリ | 15,812 KB |
最終ジャッジ日時 | 2025-10-13 16:38:55 |
合計ジャッジ時間 | 8,437 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 TLE * 1 |
other | -- * 20 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for(int i =0; i < (n); i++) using ll = long long int; string s; ll f(int pos, bool tight, bool has8) { if (pos == s.size()) { return has8; } ll res = 0; int limit = tight ? (s[pos] - '0') : 9; for (int d = 0; d <= limit; d++) { bool new_tight = tight && (d == limit); bool new_has8 = has8 || (d == 8); res += f(pos + 1, new_tight, new_has8); res %= 998244353; } return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); cin >> s; cout << f(0, true, false) << endl; return 0; }