码迷,mamicode.com
首页 > 其他好文 > 详细

POJ - 2406

时间:2018-02-09 20:41:49      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:++   markdown   bre   body   oid   div   uil   build   amp   

/*H E A D*/
int nxt[maxn];
char P[maxn];
void buildNext(){
    nxt[1]=0;
    int j=0,m=strlen(P+1);
    rep(i,2,m){
        while(j&&P[i]!=P[j+1])j=nxt[j];
        if(P[i]==P[j+1])j++;
        nxt[i]=j;
    } 
}
int main(){
    while(~s1(P)){
        int m=strlen(P+1);
        if(P[1]==‘.‘&&m==1)break;
        buildNext();
        if(m%(m-nxt[m])==0) printf("%d\n",m/(m-nxt[m]));
        else printf("1\n");//note
    }
    return 0;
}

POJ - 2406

标签:++   markdown   bre   body   oid   div   uil   build   amp   

原文地址:https://www.cnblogs.com/caturra/p/8436325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!