对于数组s[0~n-1],计算next[0~n](多计算一位)。
考虑next[n],假设t=n-next[n],如果n%t==0,则t就是问题的解,否则解为1。
这样考虑:
比如字符串"abababab",
a b a b a b a b *
next -1 0 1 2 3 4 5 6 7
考虑这样的模式匹配,将"ababa...
分类:
其他好文 时间:
2014-08-04 21:38:08
阅读次数:
294
//next_permutation全排列
# include
# include
# include
using namespace std;
struct node
{
int w;
int v;
};
struct node a[10010];
int max1(int x,int y)
{
return x>y?x:y;
}
int main()
{
int i,n,d,fl...
分类:
其他好文 时间:
2014-08-04 21:33:18
阅读次数:
279
对于KMP算法中next函数的应用
题意是对于一个字符串的前缀和后缀比较是否相等,再把相等的可能按字符串长度进行输出
#include
#include
#include
using namespace std;
int len;
int next[1000005];
char s[1000005];
int kmp_next()
{
int i=0,j=-1;
...
分类:
其他好文 时间:
2014-08-04 21:32:38
阅读次数:
239
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711题目大意:在母链中找到子链的位置,输出开始的位置。 1 #include 2 #include 3 using namespace std; 4 int lens,lenc,next[10000.....
分类:
其他好文 时间:
2014-08-04 21:17:57
阅读次数:
174
题意是求第一个字符的前缀和后一个字符串的后缀最大的公共序列,并输出。。。
将两个字符串合并,求出kmp中的next数组就行,但要注意不要大于某个字符串的长度;
#include
#include
const int N = 50005;
#define min(a,b) ((a)
char s1[N], s2[N], s3[N * 2];
int next[N * 2];...
分类:
其他好文 时间:
2014-08-04 17:36:47
阅读次数:
207
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686题目大意:寻找子链在母链中出现的次数。 1 #include 2 #include 3 #include 4 using namespace std; 5 int next[10010],su...
分类:
其他好文 时间:
2014-08-04 17:33:17
阅读次数:
210
链表排序:算法-归并排序public class LinkedSort { private static class ListNode { int val; ListNode next; ListNode(int x) { val...
分类:
其他好文 时间:
2014-08-04 17:09:37
阅读次数:
247
学习kmp算法我最后是看的数据结构书上的一本教材学会的。。我觉得kmp相对于普通的BF算法就是避免了很多不必要的匹配,而kmp算法的精髓自然就在于next数组的运用。。。而next数组简而言之就是存储的就是模式串中第j个字符与主串中相应字符“失配”时,在模式串中需要重新和主串中失配的字符相比较的位置。。。我觉得这句概括挺好的。。。
题1:
hdu 1711 number sequen...
分类:
其他好文 时间:
2014-08-04 14:34:27
阅读次数:
277
创建临时表空间
CREATE TEMPORARY TABLESPACE test_temp
TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
创建用户表...
分类:
数据库 时间:
2014-08-04 14:33:37
阅读次数:
386