http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1744
1 #include<stdio.h>
2 #include<string.h>
3 char str[5005];
4 int main()
5 {
6 int len,cnt;
7 while(scanf("%s",str)!=EOF)
8 {
9 len=strlen(str);
10 cnt=len;
11 for(int i=0;i<len;i++)
12 {
13 for(int j=1;j<=i&&j<=len-1;j++)
14 {
15 if(str[i-j]==str[i+j])
16 cnt++;
17 else
18 break;
19 }
20 for(int j=1;j<=len-1-i&&j-1<=i;j++)
21 {
22 if(str[i-j+1]==str[i+j])
23 cnt++;
24 else
25 break;
26 }
27 }
28 printf("%d
",cnt);
29 }
30 return 0;
31 }