zoukankan      html  css  js  c++  java
  • HDU 1358

    POJ 2406的升级版

    大同小异

    #include <iostream>
    #include "stdio.h"
    #include <string.h>
    #include <cstring>
    using namespace std;
    #define n 1000010
    int next[n],l;
    char s[n];
    void getNext(){
        int j,k;
        next[0]=-1;
        j=0;
        k=-1;
        while(j<l){
            if(k==-1||s[j]==s[k])    {
                j++;
                k++;
                next[j]=k;
            }
            else
                k=next[k];
        }
        //for(int i=1;i<=l;i++)cout<<next[i]<<endl;
    }
    int main(){
        int game=0;
        while(scanf("%d",&l)!=EOF){
            if(l==0)break;
            game++;
            scanf("%s",s);
            getNext();
            printf("Test case #%d ",game);

       /*for(int i=2;i<k;i++){
                if(i%(i-next[i])==0)
                printf("%d %d ",i,i/(i-next[i]));
            }
            int j=1;
            for(int i=k+k;i<=l;i+=k){
                printf("%d %d ",i,j+1);
                j++;
            }*/
            for(int i=1;i<l;i++)
            {
                if(next[i+1]!=0&&(i+1)%(i+1-next[i+1])==0)
                {
                    printf("%d %d ",i+1,(i+1)/(i+1-next[i+1]));
                }
            }
            printf(" ");
        }
        return 0;
    }

  • 相关阅读:
    remove all event handlers from a control
    clone Control event handlers at run time
    EventHandlerList z
    code
    From delegates to lambdas z
    tpl Dataflow for net 4.0
    FlowLayoutPanel autowrapping doesn't work with autosize
    easyui radio 取值和赋值
    jquery hide和show方法
    java设计模式 工厂模式
  • 原文地址:https://www.cnblogs.com/Mr-Xu-JH/p/3860570.html
Copyright © 2011-2022 走看看