#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
const int maxn = 1000000 ;
char str[ maxn ];
int next[ maxn ];
int len ;
void get_next()
{
next[ 0 ] = -1 ;
int j = 0 , k = -1 ;
while( j < len )
{
if( k == -1 || str[ j ] == str[ k ] )
{
j++ ;
k++ ;
next[ j ] = k ;
}
else
k = next[ k ] ;
}
}
int main()
{
int Case;
scanf( "%d", &Case );
while( Case-- ){
//gets( str );
scanf( "%s", str );
len = strlen( str ) ;
get_next();
if( len % ( len - next[ len ] ) == 0 && len / ( len - next[ len ] ) > 1 )
printf( "%d\n" , len / ( len - next[ len ] ) );
else
printf( "1\n" ) ;
}
return 0;
}
Windy's S(II)
最新推荐文章于 2019-11-03 14:31:46 发布