poj 3461 字符串单串匹配--KMP或者字符串HASH

http://poj.org/problem?id=3461


先来一发KMP算法:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

#define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i

再来一发字符串HASH

我的字符串HASH模板在http://blog.csdn.net/u011026968/article/details/38460357

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

#define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define rep(i,s,e) for(int i=s;ibl)
    {
        strcpy(tmp,a);
        strcpy(a,b);
        strcpy(b,tmp);
    }
    ull t=1,ah=0,bh=0;
    for(int i=0;i


你可能感兴趣的:(字符串Hash,字符串处理-KMP)