Topic links
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong Longll;4 5InlineintRead ()6 {7 intx=0, f=1;CharCh=GetChar ();8 while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}9 while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();}Ten returnx*F; One } A - /********************************************************************/ - the Const intMAXN = 3e6+6; - CharS[MAXN]; - intNEXT[MAXN]; - + intMain () { - + //int n; n = read (); Ascanf"%s", s+1); at intLen = strlen (s+1); -next[1] =0; - intK =0; - for(inti =2; I <= len;i++){ - while(k >0&& s[k+1] !=S[i]) { -K =Next[k]; in } - if(s[k+1] ==S[i]) tok++; +Next[i] =K; - } the intTMP =0; * intf =1; $ for(inti =1; I <= len;i++){Panax Notoginseng if(i% (i-next[i]) = =0){ -TMP = (I-next[i]); the } + ElseTMP =1; A if(f) { theprintf"%d", TMP); +f =0; - } $ Elseprintf"%d", TMP); $ } -printf"\ n"); - for(inti =1; I <= tmp;i++){ theprintf"%c", S[i]); - }Wuyiprintf"\ n"); the - return 0; Wu}
It's all Qiushi brother.