結果
問題 | No.2279 OR Insertion |
ユーザー |
![]() |
提出日時 | 2023-04-19 00:17:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 1,795 ms |
コンパイル使用メモリ | 198,992 KB |
最終ジャッジ日時 | 2025-02-12 10:04:47 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/modint> using namespace atcoder; using mint = modint998244353; int main() { int N; string S; cin >> N >> S; mint ans = 0; for (int k = 0; k < N; k++) { vector<mint> dp(N + 1, 0); dp.at(0) = 1; for (int i = 0; i < N; i++) { if (i - k < 0 || S.at(i - k) == '0') dp.at(i + 1) = 2 * dp.at(i); else dp.at(i + 1) = 2 * dp.at(i) - dp.at(i - k); } ans += (mint(2).pow(N - 1) - (dp.at(N) - dp.at(N - 1))) * mint(2).pow(k); } cout << ans.val() << endl; }