博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hash小结
阅读量:4579 次
发布时间:2019-06-08

本文共 785 字,大约阅读时间需要 2 分钟。

目录

1741986-20190811191753311-475466697.png

hash

int hash(ll x){    ll t = x % N;    while (h[t] && h[t] != x) t = (t + 1) % N;    return t;}int main(){    fo(i, 1, n)        x = (x * 26 + s[i] - 97) % mo;    t = hash(x);    h[t] = x;}

double hash

int hash(ll x, ll y){    ll t = x % N;    while (h[t][0] && (h[t][0] != x || h[t][1] != y)) t = (t + 1) % N;    return t;}int main(){    fo(i, 1, n)    {        x = (x * 26 + s[i] - 97) % mo;        y = (y * 26 + s[i] - 97) % mo1;    }    t = hash(x, y);    h[t][0] = x, h[t][1] = y;}

hash字符串中的子串

int main(){    cf[0] = 1;    fo(i, 1, n) cf[i] = cf[i - 1]  * 26;     fo(i, 1, n)        qz[i] = (qz[i - 1] * 26 + s[i] - 97) % mo;//  对于[i~j]的hash值     (qz[j] - qz[i - 1] * cf[j - i + 1] % mo + mo) % mo;}

树hash

\(hash\)用来比较树是否同构。

转载于:https://www.cnblogs.com/jz929/p/11336285.html

你可能感兴趣的文章
Nmap 7.70新增功能——扫描主机所有IP
查看>>
二分图
查看>>
UVA10559&POJ1390 Blocks 区间DP
查看>>
《Linux内核》读书笔记 第十八章
查看>>
【AS3代码】擦窗户效果(也就是流行的妄撮游戏)
查看>>
[bzoj 3289] Mato的文件管理
查看>>
Flutter学习笔记(五)
查看>>
Linux zip命令详解
查看>>
vSphere的exsi root密码忘记了
查看>>
svn的安装过程
查看>>
pure的bug记录2
查看>>
NSCopying简析
查看>>
python抓取51CTO博客的推荐博客的全部博文,对标题分词存入mongodb中
查看>>
oracle 用户 角色 权限
查看>>
P2083 找人
查看>>
MySQL 分区知识点(三)
查看>>
使用pipreqs生成项目依赖
查看>>
android 二维码生成
查看>>
sql server2008 R2安装总结
查看>>
linux命令行快捷键
查看>>