Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
136421 hjx21112 统计回文子串 C++ Accepted 127 MS 284 KB 464 2025-11-13 18:21:47

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; int main() { char s[5050]; int i,j,l; while (cin>>s) { l=strlen(s); int k=0; for (i=0;i<l;i++) { for (j=0;i-j>=0 and i+j<l;j++) { if (s[i-j]==s[i+j]) k++; else break; } if (s[i]!=s[i+1]) continue; for (j=0;i-j>=0 && i+1+j<l;j++) { if (s[i-j]==s[i+1+j]) k++; else break; } } cout<<k<<endl; } return 0; }