This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

30
TangDou/XiTi/1183.cpp Normal file
View File

@@ -0,0 +1,30 @@
#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;
}