用来求字符串最长回文串或者回文串的总数量
char a[N],c[N];
int radius[N];
int init()
{
int n=strlen(a);
for(int i=1,j=0;i<=2*n;j++,i+=2){
c[i]='#';
c[i+1]=a[j];
}
c[0]='$';
c[2*n+1]='#';
c[2*n+2]='@';
c[2*n+3]='
';
return 2*n+1;
}
ll manacher(){
int mx=0,id=0,n=init();
int maxn=0;
ll ans=0;
for(int i=1;i<=n;i++)
{
radius[i]=mx>i ? min(mx-i,radius[2*id-i]) : 1 ;
while(c[i-radius[i]]==c[i+radius[i]]) radius[i]++;
if(radius[i]+i>mx) mx=radius[i]+i,id=i;
ans+=radius[i]/2;
maxn=max(maxn,radius[i]);
}
return ans; //回文串数量
return maxn; //最长回文串
}
int main()
{
scanf("%s",a);
cout<<manacher();
return 0;
}