結果
問題 |
No.2867 NOT FOUND 404 Again
|
ユーザー |
![]() |
提出日時 | 2024-09-12 10:59:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 363 ms / 3,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 3,305 ms |
コンパイル使用メモリ | 248,632 KB |
実行使用メモリ | 27,836 KB |
最終ジャッジ日時 | 2024-09-12 11:00:06 |
合計ジャッジ時間 | 9,430 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int MAXN = 1000005, MOD = 998244353; int n, f[MAXN][2][3], ans; string s; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> s; n = s.size(), s = ' ' + s; f[0][1][0] = 1; for(int i = 0; i < n; ++i) { for(bool lim : {0, 1}) { for(int op : {0, 1, 2}) { int r = s[i + 1] - '0'; for(int num = 0; num <= (lim ? r : 9); ++num) { if(!(op == 2 && num == 4)) { f[i + 1][lim & (num == r)][(num == 4 ? 1 : (op == 1 && num == 0 ? 2 : 0))] = (f[i + 1][lim & (num == r)][(num == 4 ? 1 : (op == 1 && num == 0 ? 2 : 0))] + f[i][lim][op]) % MOD; } } } } } for(bool lim : {0, 1}) { for(int op : {0, 1, 2}) { ans = (ans + f[n][lim][op]) % MOD; } } cout << (ans - 1 + MOD) % MOD; return 0; }