#include
#include
#include
#include
using
namespace std;
const
int maxn=
1e6+7;
int next[maxn]
;string s,t;
void
get_next
(string str)
}void
kmp()}
intmain()
#include
#include
#include
#include
#include
using
namespace std;
typedef
unsigned
long
long ull;
const ull mag=
1e4+7;
const
int maxn=
1e5+7;
ull magic[maxn]
,hs[maxn]
,ht[maxn]
;void
get_mag
(int n)
void
get_hash
(string s,ull h)
ull get_int
(int l,
int r,ull h)
intmain()
#include
#include
#include
#include
#include
using
namespace std;
const
int alp =26;
const
int maxn=
5e5+7;
int head,tail;
char keyword[51]
;char str[maxn*2]
;struct node
}*q[maxn]
;void
insert
(char
*str,node *root)
p->count++
;//到了單詞的末尾了,標記末尾
}void
bfail
(node *root)
p=p-
>fail;
//如果沒找到,就沿著失敗指標繼續找}if
(p==
null
)//如果找不到了,就把它的這個兒子的失敗指標指向root
temp-
>next[i]
->fail=root;
} q[head++
]=temp-
>next[i]
;//將這個點放入佇列}}
}int
query
(node *root,
char str)
}return cnt;
//返回答案
}
多行字串 模板字串
多行字串 下面是普通字串的寫法 普通字串 var l abcd console.log l 編譯結果 如何讓讓乙個字串獨佔多行呢?就需要用到es6 裡的多行字串 多行字串 var i ab cd console.log i 編譯結果 再說說拼接字串,一般情況我們是如何拼接字串的呢?看下面 正常拼接字...
模板 字串 字串匹配
計算next陣列的方法是對於長度為n的匹配串,從0到n 1位依次求出字首字尾最大匹配長度。下面的寫法是僅僅檢測有沒有匹配然後返回第乙個匹配位置,而不是返回所有匹配位置。include include include using namespace std const int n 100 char s...
模板字串
es6 的模板字串,使用更簡潔 語法 模板字串拼接 let str he is he is a 插入變數的時候也不需要再使用加號 了,而是把變數放入 即可。中可以放js任意的表示式 1 運算表示式 2 可以是物件的屬性 3 可以是函式的呼叫 標籤模板 tagfn 他叫 身高 公尺。標籤 模板字串 定...