摘要: ###拉链法 ###字符串前缀hash $ s="ABCDDDC"\ P=131 (or) 13331,M=2^(64)\ c++中unsigned int 溢出相当于自动对2^(64)取模\ h[0]=0;\ h[1]="A"的hash值\ h[2]="AB"的hash值\ h[3]="ABC"的 阅读全文
posted @ 2020-11-24 22:23 30天CF上蓝!!! 阅读(163) 评论(0) 推荐(0) 编辑
摘要: ###map,Hash表,unordered_map更优 int n; map<int,int>Hash; int query(int x) { if(Hash.count(x)==0) Hash[x]=++n; return Hash[x]; } int main() { for(int i=0; 阅读全文
posted @ 2020-11-24 20:25 30天CF上蓝!!! 阅读(72) 评论(0) 推荐(0) 编辑