結果
問題 | No.2867 NOT FOUND 404 Again |
ユーザー |
![]() |
提出日時 | 2024-08-30 21:50:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 338 ms / 3,000 ms |
コード長 | 806 bytes |
コンパイル時間 | 4,164 ms |
コンパイル使用メモリ | 255,496 KB |
最終ジャッジ日時 | 2025-02-24 03:00:17 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ string s; cin>>s; vector dp(2,vector<mint>(3,0)); dp[0][0] = 1; string t = "404"; rep(i,s.size()){ int d = s[i]-'0'; vector ndp(2,vector<mint>(3,0)); rep(j,2){ rep(k,3){ rep(l,10){ if(j==0 && l>d)continue; int nj = j; if(l < d)nj = 1; int nk; if(t[k]-'0'==l)nk = k+1; else if(l==4)nk = 1; else nk = 0; if(nk==3)continue; ndp[nj][nk] += dp[j][k]; } } } swap(dp,ndp); } mint ans = 0; rep(i,2)rep(j,3)ans += dp[i][j]; ans--; cout<<ans.val()<<endl; return 0; }