标签:pow ret ase har char s ash code int init
char s[maxn];
int len;
const ull base=233;
ull hashsum[maxn];
ull pw[maxn];
void hash_init()
{
pw[0]=1;
hashsum[0]=1;//
for (int i=1;i<=len;i++) pw[i]=pw[i-1]*base;//hash power
for (int i=1;i<=len;i++) hashsum[i]=hashsum[i-1]*base+s[i-1];//hash: hashsum[i] <- s[i-1]
}
ull gethash(int i,int j)
{
i++,j++;
return hashsum[j]-hashsum[i-1]*pw[j-i+1];
}
标签:pow ret ase har char s ash code int init
原文地址:https://www.cnblogs.com/reshuffle/p/12687170.html