'commit'
This commit is contained in:
30
TangDou/XiTi/1183.cpp
Normal file
30
TangDou/XiTi/1183.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user