Suffix array feature EMM:
Just follow the next step. /
A suffix array can also be done
From small to large enumeration length I, if the substring of length i is exactly repeated len/i times, should meet len% i = = 0 and rank[0]-rank[i] = = 1 (the entire string of the rank of the suffix of the beginning of the position of the class is greater than the 1 (the suffix of I position is lower than the total string suffix)) and he Ight[rank[0]] = = Len-i (the length of the longest common prefix of the entire string and the string of one rank below it is the total length minus the length of this loop section) these conditions
#include <iostream>#include<cstdio>#include<sstream>#include<cstring>#include<map>#include<cctype>#include<Set>#include<vector>#include<stack>#include<queue>#include<algorithm>#include<cmath>#defineRap (i, A, n) for (int i=a; i<=n; i++)#defineRep (I, A, n) for (int i=a; i<n; i++)#defineLap (I, a, n) for (int i=n; i>=a; i--)#defineLEP (i, A, n) for (int i=n; i>a; i--)#defineRD (a) scanf ("%d", &a)#defineRlld (a) scanf ("%lld", &a)#defineRC (a) scanf ("%c", &a)#defineRS (a) scanf ("%s", a)#defineMOD 2018#defineLL Long Long#defineULL unsigned long Long#definePair Pair<int, int>#defineMem (A, B) memset (A, B, sizeof (a))#define_ Ios_base::sync_with_stdio (0), Cin.tie (0)//freopen ("1.txt", "R", stdin);using namespacestd;Const intMAXN = 1e6+Ten, INF =0x7fffffff;intNEX[MAXN];voidGet_next (Char*s) { intLen =strlen (s); intJ, K; J=0, k =-1, nex[0] = -1; while(J <Len) { if(k = =-1|| S[J] = =s[k]) nex[++J] = + +K; Elsek=Nex[k]; }}CharS[MAXN];intMain () { while(~rs (s) && s[0] !='.') {Get_next (s); intn =strlen (s); if(n% (n-nex[n]) = =0) cout<< N/(N-nex[n]) <<Endl; Elsecout<<1<<Endl; } return 0;}
Power Strings POJ-2406 (Next water pitch | | Suffix array)