結果
問題 | No.2541 Divide 01 String |
ユーザー |
|
提出日時 | 2023-11-24 22:24:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 1,760 ms |
コンパイル使用メモリ | 166,008 KB |
実行使用メモリ | 7,040 KB |
最終ジャッジ日時 | 2024-09-26 09:31:40 |
合計ジャッジ時間 | 2,131 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define app push_back const int p=998244353; const int maxn=1e6+5; int dp[maxn][2]; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n;cin>>n;string s;cin>>s; dp[1][s[0]=='1']=1; for(int i=1;i<n;++i) { dp[i+1][s[i]=='1']+=dp[i][1];dp[i+1][s[i]=='1']%=p; dp[i+1][s[i]=='1']+=dp[i][0];dp[i+1][s[i]=='1']%=p; dp[i+1][1]+=dp[i][1];dp[i+1][1]%=p; } cout<<dp[n][1]; return 0; }