Codeforces Beta Round #7, problem: (D) Palindrome Degree
[cpp]#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
__int64 dp[5000000+5];
char s[5000000+5];
using namespace std;
int main(void)
{
__int64 ans=0,l=0,r=0,k=1;
scanf("%s",s);
for(int i=0;s[i];i++)
{
l=l*33+s[i]-'a';
r=r+(s[i]-'a')*k;
k=k*33;
if(l==r)
dp[i+1]=dp[(i+1)/2]+1;
ans+=dp[i+1];
}
cout<<ans<<endl;
return 0;
}
补充:软件开发 , C++ ,