哈希技巧

字符串hash

const int mod =  1e9 + 7 | 1e9 + 9;孪生质数
s[]    a  b   c    d
hash[] a ab abc abcd
hash(2,3) = bc = hash[3] - hash[2 - 1] * power(mod,3 - 2 + 1) = abc - axx = bc;

序列hash

树hash

图hash

posted @ 2022-04-01 23:13  XDU18清欢  阅读(31)  评论(0)    收藏  举报