关于next的解释原文:点点点
//#include <bits/stdc++.h> #include<cstdio> #include<string.h> #include<algorithm> using namespace std; const int N=1e6+10; char s[N]; int Next[N],len; void GetNext() { int i=0,j=-1; Next[0]=-1; while(i<len) { if(j==-1||s[i]==s[j]) Next[++i]=++j; else j=Next[j]; } } int main() { while(~scanf("%s",s)) { if(strcmp(s,".")==0) break; len=strlen(s); GetNext(); if(len%(len-Next[len])==0) printf("%d ",len/(len-Next[len])); else printf("%d ",1); } return 0; }