![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串hash
qq_36911709
这个作者很懒,什么都没留下…
展开
-
poj3461 Oulipo(字符串哈希)
poj3461http://poj.org/problem?id=3461字符串hash模板题。给你2个串s1,s2(长度n,m),问s1在s2中出现几次。字符串hash步骤:1、 取一个质数p我一般取999983。据说应该再模一个q(一般取1e9+7),但模了有时会超时。于是我一般不模q,让它自然溢出。但有一种数据专门卡这种自然溢出,于是我写一种假的双hash:将q作为另一...原创 2018-07-12 19:35:19 · 581 阅读 · 0 评论 -
poj2406Power Strings & bzoj2795A Horrible Poem(最小循环节长度)
poj2406http://poj.org/problem?id=2406 求每个字符串的最小循环节的长度。这题不卡时限。直接取子串比对即可。#include<iostream>#include<cstdio>#include<cstring>#include<string>#define p 999983#defin...原创 2018-07-12 20:07:24 · 239 阅读 · 0 评论 -
poj2752Seek the Name, Seek the Fame
poj2752http://poj.org/problem?id=2752 在每个字符串中求出所有既是前缀又是后缀的子串长度。很水的hash。直接暴力枚举长度,再比对hash值即可。注意:s既是s的前缀,又是s的后缀。#include<iostream>#include<cstdio>#include<algorithm>#inc...原创 2018-07-12 20:12:02 · 118 阅读 · 0 评论 -
bzoj3916 friends
bzoj3916https://www.lydsy.com/JudgeOnline/problem.php?id=3916 一个串s2由两个s,中间夹一个字符c组成,求s。若s不存在,"NOT POSSIBLE";若s不唯一,"NOTUNIQUE";否则;输出s。其实主要是hash+模拟。hash和power下标要好好算一下,还得分类讨论(c在前一半/c在后一半)注意:是看s是...原创 2018-07-12 20:29:18 · 300 阅读 · 0 评论