include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
typedef long long ll;
ll dp[3][N]={0};
char s[N];
int main(){
scanf("%s",s+1);
int len = strlen(s+1);
// cout<<len<<endl;
ll sum = 0;
for(int i=0;i<=2;i++){
for(int j=i;j<=len;j++){
if(i==0) dp[i][j] = 1;
else{
dp[i][j] = dp[i][j-1] + dp[i-1][j-1];
for(int k=j-1;;k--){
if(j-k > i) break;
if(s[k] == s[j]){
dp[i][j] -= dp[i-(j-k)][k-1];
break;
}
}
}
}
}
sum = dp[0][len]+dp[1][len]+dp[2][len];
cout<<sum<<endl;
}
1020 Delete At Most Two Characters (35 分)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.