結果

問題 No.2867 NOT FOUND 404 Again
ユーザー cho435cho435
提出日時 2024-08-30 23:12:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 3,000 ms
コード長 1,855 bytes
コンパイル時間 4,593 ms
コンパイル使用メモリ 269,288 KB
実行使用メモリ 59,052 KB
最終ジャッジ日時 2024-08-30 23:12:39
合計ジャッジ時間 8,638 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 167 ms
59,020 KB
testcase_04 AC 168 ms
59,028 KB
testcase_05 AC 168 ms
59,052 KB
testcase_06 AC 168 ms
59,016 KB
testcase_07 AC 167 ms
58,996 KB
testcase_08 AC 167 ms
59,008 KB
testcase_09 AC 167 ms
58,988 KB
testcase_10 AC 182 ms
58,916 KB
testcase_11 AC 168 ms
58,896 KB
testcase_12 AC 167 ms
58,960 KB
testcase_13 AC 167 ms
58,920 KB
testcase_14 AC 167 ms
58,928 KB
testcase_15 AC 165 ms
58,896 KB
testcase_16 AC 168 ms
58,932 KB
testcase_17 AC 185 ms
58,892 KB
testcase_18 AC 139 ms
58,920 KB
testcase_19 AC 174 ms
59,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)

template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

using mint=atcoder::modint998244353;

int main(){
	string s;
	cin>>s;
	int n=s.size();
	vector<vector<mint>> dp(n+1,vector<mint>(6));
	dp.at(0).at(3)=1;
	rep(i,0,n){
		rep(j,0,10){
			if(j<s.at(i)-'0'){
				if(j==0){
					dp.at(i+1).at(0)+=dp.at(i).at(3);
					dp.at(i+1).at(2)+=dp.at(i).at(4);
					dp.at(i+1).at(0)+=dp.at(i).at(5);
				}else if(j==4){
					dp.at(i+1).at(1)+=dp.at(i).at(3);
					dp.at(i+1).at(1)+=dp.at(i).at(4);
				}else{
					dp.at(i+1).at(0)+=dp.at(i).at(3);
					dp.at(i+1).at(0)+=dp.at(i).at(4);
					dp.at(i+1).at(0)+=dp.at(i).at(5);
				}
			}else if(j==s.at(i)-'0'){
				if(j==0){
					dp.at(i+1).at(3)+=dp.at(i).at(3);
					dp.at(i+1).at(5)+=dp.at(i).at(4);
					dp.at(i+1).at(3)+=dp.at(i).at(5);
				}else if(j==4){
					dp.at(i+1).at(4)+=dp.at(i).at(3);
					dp.at(i+1).at(4)+=dp.at(i).at(4);
				}else{
					dp.at(i+1).at(3)+=dp.at(i).at(3);
					dp.at(i+1).at(3)+=dp.at(i).at(4);
					dp.at(i+1).at(3)+=dp.at(i).at(5);
				}
			}
			if(j==0){
				dp.at(i+1).at(0)+=dp.at(i).at(0);
				dp.at(i+1).at(2)+=dp.at(i).at(1);
				dp.at(i+1).at(0)+=dp.at(i).at(2);
			}else if(j==4){
				dp.at(i+1).at(1)+=dp.at(i).at(0);
				dp.at(i+1).at(1)+=dp.at(i).at(1);
			}else{
				dp.at(i+1).at(0)+=dp.at(i).at(0);
				dp.at(i+1).at(0)+=dp.at(i).at(1);
				dp.at(i+1).at(0)+=dp.at(i).at(2);
			}
		}
	}
	mint ans=0;
	rep(i,0,6) ans+=dp.at(n).at(i);
	cout<<(ans-1).val()<<endl;
}
0