Run ID:113998
提交时间:2025-03-18 13:47:44
#include <iostream> #include <cstring> #include <cstdio> using namespace std; const int N = 5001; char str[N]; int solve() { int ans = 0, len = strlen(str); for ( int i = 0; i < len; i++ ) { for ( int j = 0; i - j >= 0 && i + j < len; j++ ) { if ( str[i - j] == str[i + j] ) { ans++; } else { break; } } if ( str[i] != str[i + 1] ) continue; for ( int j = 0; i - j >= 0 && i + 1 + j < len; j++ ) { if ( str[i - j] == str[i + 1 + j] ) { ans++; } else { break; } } } return ans; } int main () { while ( scanf("%s", str) != EOF ) { printf("%d\n", solve()); } return 0; }