結果
問題 |
No.3242 Count 8 Included Numbers (Hard)
|
ユーザー |
![]() |
提出日時 | 2025-08-25 00:14:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 3,384 ms |
コンパイル使用メモリ | 283,960 KB |
実行使用メモリ | 136,068 KB |
最終ジャッジ日時 | 2025-08-25 00:14:58 |
合計ジャッジ時間 | 9,008 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; vector dp(s.size() + 1, vector(2, vector<mint>(2, 0))); dp[0][1][0] = 1; rep(i, s.size()) { int d = s[i] - '0'; rep(eq, 2) rep(cont, 2) { for (int dig = 0; dig <= (eq ? d : 9); dig++) { dp[i + 1][eq && (dig == d)][cont || (dig == 8)] += dp[i][eq][cont]; } } } cout << (dp[s.size()][0][1] + dp[s.size()][1][1]).val() << '\n'; return 0; }