首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Codeforces Beta Round #七, problem: (D) Palindrome Degree

2012-09-11 
Codeforces Beta Round #7, problem: (D) Palindrome Degree#includeiostream#includecstdio#include

Codeforces Beta Round #7, problem: (D) Palindrome Degree

#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;}


热点排行