问一个字符串的子序列是回文串的个数;
dp
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char s[70];
long long dp[70][70];
int main() {
int cas;
//freopen("input.txt","r",stdin);
scanf("%d",&cas);
while(cas--){
scanf("%s",s+1);
int n=strlen(s+1);
memset(dp,0,sizeof dp);
for(int k=0;k<n;k++) {
for(int l=1;l<=n;l++) {
int r=l+k;if(r>n) break;
if(s[l]!=s[r]) {
dp[l][r] = dp[l+1][r]+dp[l][r-1]-dp[l+1][r-1];
}else {
dp[l][r] = dp[l+1][r]+dp[l][r-1];
dp[l][r] ++;
}
}
}
//printf("%d\n",dp[1][n]);
cout<<dp[1][n]<<endl;
}
return 0;
}