#include #include using namespace std; int SearchPalidrome(string, int); int main(int argc, const char * argv[]) { string sentence; int maxLength = 0; cin >> sentence; for (int i = 0; i < sentence.length() - 1; i++){ for (int j = i; j < sentence.length(); j++) { string temp =sentence.substr(i, sentence.length() - j); int num = SearchPalidrome(temp, 0); if(num == sentence.length()) num -= 2; if (num > maxLength) maxLength = num; } } cout << maxLength << endl; return 0; } int SearchPalidrome(string sentence, int layer) { if (sentence.length()== 1) return ++layer; if (sentence.length()== 0) return layer; if (sentence[0] == sentence[sentence.length() - 1]) { string temp =sentence.substr(1, sentence.length() - 2); return SearchPalidrome(temp, layer += 2); } return 0; }