于是 dp[i][j] = dp[i+1][j] + dp[i][j-1] - dp[i+1][j-1];
typedef long long LL ; const int maxn = 68 ; char str[maxn] ; LL dp[maxn][maxn] ; LL DP(int l , int r){ if(l > r) return dp[l][r] = 0 ; if(dp[l][r] != -1) return dp[l][r] ; if(l == r) return dp[l][r] = 1 ; if(str[l] == str[r]) return dp[l][r] = DP(l+1 , r) + DP(l , r-1) + 1 ; else return dp[l][r] = DP(l+1 , r) + DP(l , r-1) - DP(l+1 , r-1) ; } int main(){ int t ; cin>>t ; while(t--){ scanf("%s" , str) ; memset(dp , -1 , sizeof(dp)) ; printf("%lld\n" , DP(0 , strlen(str) - 1) ) ; } return 0 ; }