#include "string"
#include "iostream"
#include "cstdio"
#include "cmath"
#include "set"
#include "queue"
#include "vector"
#include "cctype"
#include "sstream"
#include "cstdlib"
#include "cstring"
#include "stack"
#include "ctime"
#include "algorithm"
#define pa pair<int,int>
#define Pi M_PI
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long LL;
const int M=55;
int next[1000005];
string s;
void getnext()
{
int i=0,j=-1;
next[0]=-1;
int len=s.length();
while(i<len)
{
if(s[i]==s[j]||j==-1)
{
i++;
j++;
next[i]=j;
}
else
j=next[j];
}
}
int main()
{
while(cin>>s&&s[0]!='.')
{
int len=s.length();
getnext();
if(len%(len-next[len])==0)
printf("%d\n",len/(len-next[len]));
else
printf("1\n");
}
return 0;
}
POJ 2406 Power Strings(循环节)
最新推荐文章于 2022-07-21 20:55:14 发布