結果
問題 |
No.3242 Count 8 Included Numbers (Hard)
|
ユーザー |
![]() |
提出日時 | 2025-08-30 15:14:47 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 201 ms / 2,000 ms |
コード長 | 552 bytes |
コンパイル時間 | 905 ms |
コンパイル使用メモリ | 91,188 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-08-30 15:14:53 |
合計ジャッジ時間 | 5,171 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include<iostream> #include<vector> using namespace std; using ll=long long; constexpr ll mod=998244353; int main(){ string s; cin>>s; int n=s.size(); vector<vector<ll>>dp(2,vector<ll>(2,0)); dp[0][0]=1; for(char c:s){ c-='0'; vector<vector<ll>>ndp(2,vector<ll>(2,0)); for(int i=0;i<2;i++)for(int j=0;j<2;j++){ for(int k=0;k<(i?10:c+1);k++){ ndp[i||(k<c)][j|(k==8)]+=dp[i][j]; } } dp=move(ndp); for(int i=0;i<2;i++)for(int j=0;j<2;j++)dp[i][j]%=mod; } cout<<(dp[0][1]+dp[1][1])%mod<<endl; }