Files
python/TangDou/XiTi/1183.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

31 lines
711 B
C++

#include <bits/stdc++.h>
using namespace std;
/*
qiuchangdu(string s)
字符串长度是奇数
返回 字符串长度
否则
判断是否是对称的
如果是对称的,则返回 qiuchangdu(字符串s的一半)
否则 返回 字符串长度
*/
int qiuchangdu(string s) {
if (s.length() % 2 == 1) {
return s.length();
} else {
string temp = s;
reverse(temp.begin(), temp.end());
if (s == temp) return qiuchangdu(s.substr(0, s.length() / 2));
else return s.length();
}
}
int main() {
string s;
cin >> s;
cout << qiuchangdu(s) << endl;
return 0;
}