ans

zhaocong 2022-04-03 10:09:22 30 返回题目

#include<bits/stdc++.h>

using namespace std;

long long dp[10010],n;

char s[10010];

string a[10010],ss;

set words;

bool check(int l,int r){

string ss="";

for(int i=l;i<=r;i++) ss+=s[i];

return words.find(ss) != words.end();

}

int main(){

dp[0]=1;

scanf("%lld",&n);

for(int i=1;i<=n;i++){

	cin>>ss;

	words.insert(ss);

}

cin>>s+1;

int len=strlen(s+1)-1;

for(int i=1;i<=len;i++) for(int j=0;j<=i-1;j++) if(check(j+1,i)) dp[i]+=dp[j];

cout<<dp[len];

return 0;

}

{{ vote && vote.total.up }}

共 1 条回复

wuhongzhen

WOW