摘要: 本来这个题是用字典树等等神算法实现的……结果我直接暴搞的。。。先开始写的LCS,后来超时惨了……就在网上查……结果发现LCS完全没必要,只用写一个o(n)的判断就可以了……#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>struct dict{ char s[30]; int len;};dict d[10010];int judge(char a[],char b[]){ int sum=0; int pos=-1; int size=strlen(b); 阅读全文
posted @ 2011-07-24 23:42 ω 提拉米兔 ℃ 阅读(169) 评论(0) 推荐(0)
摘要: 今天对着课件写了一个串的hash ha是最初的hash值,t是最终存放在数组里面的hash值,就是数组下标。由于不同的串产生的ha不一样,让hash[t]=ha,就可以判断当前的串是不是和原来的那个串一样了#include<cstdio>#include<cstdlib>#include<cstring>#define MAXN 7003int max;int hashtable[MAXN],count[MAXN];unsigned int hash(char *s){ unsigned int seed=131; unsigned int h=0; whi 阅读全文
posted @ 2011-07-24 10:57 ω 提拉米兔 ℃ 阅读(180) 评论(0) 推荐(0)