結果
問題 |
No.2943 Sigma String of String Score Problem
|
ユーザー |
![]() |
提出日時 | 2024-10-19 14:48:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 124 ms / 3,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 2,660 ms |
コンパイル使用メモリ | 194,932 KB |
最終ジャッジ日時 | 2025-02-24 21:33:45 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { fast_io(); string s, t; cin >> s >> t; int n = s.size(), m = t.size(); mint dp[m + 1] = {}; dp[0] = 1; for (int i = 0; i < n; i++) { for (int j = m - 1; j >= 0; j--) { if (s[i] == t[j]) { dp[j + 1] += dp[j]; } } } mint ans = dp[m] * mint(2).pow(n - m); cout << ans.val() << endl; }