省选专练[CTSC2014]企鹅QQ

省选专练[CTSC2014]企鹅QQ_第1张图片

我不会Hash

学习了一下

hash就是暴力乘模数

比如19260817什么的

然后前后Hash+自然溢

#include
#include
#include
#include
#include
using namespace std;
#define LL unsigned long long 
const int N=3e4+100;
const int maxn=251;
LL St[N][maxn]={};
LL Ed[N][maxn]={};
LL tmp[N]={};
char ch[maxn]={};
int n,m,s;
int Prim[4]={19260817,233,419,231};
void Calc(int idx){
//	St[idx][0]=1;
	for(int i=1;i<=m;i++){
		St[idx][i]=(St[idx][i-1]*Prim[0]+(int)ch[i]);	
//		cout<=1;i--){
		Ed[idx][i]=(Ed[idx][i+1]*Prim[1]+(int)ch[i]);
//		cout<<(int)ch[i]<<" "<

你可能感兴趣的:(2014,其他省选,Hash)