样例没过。
#include<bits/stdc++.h>
using namespace std;
string s;
int ans = 0;
int n;
bool hv(string a)
{
string b = a;
reverse(b.begin(),b.end());
if(a == b)
{
return true;
}
return false;
}
void f(int i,int x)
{
string st;
st = "";
if(i + x >= n)
{
for(int j = i; j < n - 1; j++)
{
st += s[j];
}
}
for(int j = i; j < i + x; j++)
{
st += s[j];
}
bool t = hv(st);
if(t)
{
ans++;
}
if(i + x < n)
{
f(i + x,x + 1);
}
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
n = s.size();
f(0,1);
cout << ans;
return 0;
}
测评记录