#include <bits/stdc++.h>
const long long maxn = 1e4 + 10;
using namespace std;
long long n, dp[maxn];
string a[maxn], s;
bool compare(int x, int y) {
int len = a[y].size();
for (int i = 0; i < len; i++)
if (x - i >= 0 && len - i - 1 >= 0)
if (a[y][len - i - 1] != s[x - i])
return 0;
return 1;
}
signed main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
cin >> s;
s = " " + s;
int len = s.size() - 2;
dp[0] = 1;
for (int i = 1; i <= len; i++)
for (int j = 1; j <= n; j++) {
if (!compare(i, j))
continue;
if (i - a[j].size() >= 0)
dp[i] += dp[i - a[j].size()];
}
cout << dp[len];
return 0;
}
详细注释看071maozihan