样例都没过就A了,我也不知道错哪了,大佬们帮忙看看吧
#include <iostream>
#include <cstring>
using namespace std;
string s;
bool ck(int S, int ed)
{
for (int i = S, j = ed; i <= ed && j >= S; i ++ , j -- ) if (s[i] != s[j]) return 0;
return 1;
}
int main()
{
cin >> s;
int n = s.size();
s = ' ' + s;
int i = 1, len = 1;
int ans = 0;
while (i + len - 1 <= n)
{
//cout << i << " " << len << endl;
if (ck(i, i + len - 1)) ans ++ ;
i += len, len ++ ;
}
if (i < n && ck(i, n)) ans ++ ;
cout << ans << endl;
return 0;
}