#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
ll hasz = 0, odhasz = 0, mod = 1e9+7, mnoz = 29, ile = 1, ilete, odp = 0, os = -1;
cin >> ilete ;
for( int i = 0 ; i < ilete ; ++i ){
cin >> s;
odp = 0; hasz = 0; odhasz = 0; ile = 1;
for( int j = 0 ; j < s.size()/2 ; ++j ){
hasz += ile*(s[j]-96);
odhasz *= mnoz;
odhasz += s[s.size()-j-1]-96;
ile *= mnoz;
ile %= mod;
hasz %= mod;
odhasz %= mod;
if( hasz == odhasz ){
odp += 2;
os = j ;
hasz = 0;
odhasz = 0;
ile = 1;
}
}
if( hasz > 0 || (s.size()%2) )
odp++;
cout << odp << '\n';
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |