You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
711 B
31 lines
711 B
#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;
|
|
}
|