結果
問題 | No.2867 NOT FOUND 404 Again |
ユーザー |
![]() |
提出日時 | 2024-09-12 11:15:41 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 327 ms / 3,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 846 ms |
コンパイル使用メモリ | 88,600 KB |
実行使用メモリ | 27,836 KB |
最終ジャッジ日時 | 2024-09-12 11:15:48 |
合計ジャッジ時間 | 6,782 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> using namespace std; const int MAXN = 1e6 + 5, Mod = 998244353; int n, ans, dp[MAXN][2][3], a[3] = {4, 0, 4}; string s; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> s, n = s.size(); s = " " + s, dp[0][0][0] = 1; for (int i = 0; i < n; i++) { for (int f : {0, 1}) { int r = (f ? 9 : s[i + 1] - '0'); for (int u : {0, 1, 2}) { if (!dp[i][f][u]) continue; for (int x = 0; x <= r; x++) { if (x != a[u] || u < 2) (dp[i + 1][(x < r || f)][(x == a[u] ? u + 1 : x == a[0])] += dp[i][f][u]) %= Mod; } } } } for (int f : {0, 1}) { for (int u : {0, 1, 2}) { (ans += dp[n][f][u]) %= Mod; } } cout << (ans + Mod - 1) % Mod; return 0; }