### 题解

$$f[i][j] += f[i+1][j] (S[j-i+1]==T[i])$$
$$f[i][j] += f[i][j-1] (S[j-i+1]==T[j])$$

#include<bits/stdc++.h>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define mod 998244353
#define ll long long
#define F first
#define S second
#define mp(i, j) std::make_pair(i, j)
#define ls t[u][0]
#define rs t[u][1]
#define Re register
#define inf 1e9
#define upn 100000
#define pb(x) push_back(x)
#define N 3005
#define pi std::pair<int, int>
{
Re char ch = getchar();
Re ll ret = 0;
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) {ret = ret * 10 + ch - '0'; ch = getchar();}
return ret;
}
struct edge {
int v, w, nxt;
//    friend bool operator < (edge x, edge y) {return x.w < y.w;}
}e[N << 1];
void addedge (int u, int v, int w) { e[++tot] = (edge) {v, w, head[u]}; head[u] = tot; }
char s[N], t[N];
ll ans, f[N][N];
int main ()
{
scanf("%s", s + 1);
scanf("%s", t + 1);
int n = strlen(s + 1), m = strlen(t + 1);
fo (i, m + 1, n) t[i] = '?';
fo (i, 1, n) f[i][i] = (s[1] == t[i] || i > m) ? 2 : 0;
fo (now, 2, n)
fo (i, 1, n)
{
int j = i + now - 1;
if (j > n) break;
if (t[i] == '?' || s[now] == t[i])
(f[i][j] += f[i + 1][j]) %= mod;
if (t[j] == '?' || s[now] == t[j])
(f[i][j] += f[i][j - 1]) %= mod;
}
fo (i, m, n) ans = (ans + f[1][i]) % mod;
printf("%lld", ans);
}