摘要: 由于next[i]保存的是前i-1个字符中最大的重复子序列,那么i-next[i]就是循环节。#include#include#includeusing namespace std;int next[1000100];void getnext(char *str){ int j,k; memset(next,0,sizeof(next)); j=0; k=-1; next[0]=-1; while(str[j]) { if(k==-1 || str[j]==str[k]) next[++j]=++k; ... 阅读全文
posted @ 2013-07-05 17:39 fangguo 阅读(108) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;int next[10010];void getNext(char *str){int j,k;memset(next,0,sizeof(next));j=0;k=-1;next[0]=-1;while(str[j]){if(k==-1 || str[j]==str[k])next[++j]=++k;elsek=next[k];}}int KMP(char *s,char *t){ getNext(t); int i,j,k; i=j=0; int num=0; while(s... 阅读全文
posted @ 2013-07-05 15:09 fangguo 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeint vi[102][102][102];using namespace std;struct Point{ int a,b,c,v; Point(int x,int y,int z,int vv){a=x,b=y,c=z,v=vv;}};void pu(int &a,int &b,int c){ if(b==c) return ; if(a+b q; Point p(0,0,c,0); q.push(p); int s=c,n=a,m=b; while(!q.emp... 阅读全文
posted @ 2013-07-05 06:20 fangguo 阅读(166) 评论(0) 推荐(0) 编辑