結果
問題 |
No.2279 OR Insertion
|
ユーザー |
![]() |
提出日時 | 2023-04-21 21:52:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 731 bytes |
コンパイル時間 | 3,951 ms |
コンパイル使用メモリ | 253,652 KB |
最終ジャッジ日時 | 2025-02-12 11:32:45 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
ソースコード
#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(){ int n; cin>>n; string s; cin>>s; reverse(s.begin(),s.end()); mint ans = 0; for(int i=0;i<n;i++){ vector<mint> dp(n+1,0); mint sum = 1; dp[0] = 1; rep(j,n+1){ if(j==0)continue; if(j-1-i>=0){ if(s[j-1]=='1')sum -= dp[j-1-i]; } dp[j] = sum; sum += dp[j]; // cout<<dp[j].val()<<endl; } //cout<<dp[n].val()<<endl; ans += mint(2).pow(i) * mint(2).pow(n-1); ans -= mint(2).pow(i) * dp[n]; } cout<<ans.val()<<endl; return 0; }