結果
問題 |
No.3242 Count 8 Included Numbers (Hard)
|
ユーザー |
![]() |
提出日時 | 2025-08-26 01:53:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 319 ms / 2,000 ms |
コード長 | 678 bytes |
コンパイル時間 | 2,002 ms |
コンパイル使用メモリ | 203,452 KB |
実行使用メモリ | 136,100 KB |
最終ジャッジ日時 | 2025-08-26 01:53:22 |
合計ジャッジ時間 | 8,170 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { fast_io(); string n; cin >> n; int len = n.size(); vector dp(len + 1, vector(2, vector<mint>(2, 0))); dp[0][0][0] = 1; for (int i = 0; i < len; i++) { for (int smaller = 0; smaller < 2; smaller++) { for (int f = 0; f < 2; f++) { for (int d = 0; d <= (smaller ? 9 : n[i] - '0'); d++) { dp[i + 1][smaller || (d < n[i] - '0')][f || (d == 8)] += dp[i][smaller][f]; } } } } mint ans = dp[len][0][1] + dp[len][1][1]; cout << ans.val() << endl; }