String Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if   (i) It is of length M*L;   (ii) It can be constructed by concatenating M “diversified” substrings of S, where each of these substrings ha…
题意:给你一串字符串s,再给你两个数字m l,问你s中可以分出多少个长度为m*l的子串,并且子串分成m个长度为l的串每个都不完全相同 首先使用BKDRHash方法把每个长度为l的子串预处理成一个数字,接着根据题意直接map判重 BKDRHash:一种常用字符串hash,hash简单来说就是把一串字符串通过一些转化成为一个数字,并保证相同字符串转化的数字一样,不相同字符串转化的数字一定不一样.方法就是hash[i]=hash[i-1]*seed(进制)+str[i]-'a'+1(注意要加一,因为不…
String Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=95149#problem/I Description Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if   (i) It is o…
String Problem Description   Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if  (i) It is of length M*L;  (ii) It can be constructed by concatenating M “diversified” substrings of S, where each of…
http://acm.hdu.edu.cn/showproblem.php?pid=4821 题意:给出一个字符串,现在问你可以找出多少个长度为M*L的子串,该子串被分成L个段,并且每个段的字符串都是不同的. 思路: 看BKDRHash看了半天,很神奇~.关于这个,大家可以看一下这篇博客http://blog.csdn.net/xu20082100226/article/details/52651072. 先计算出整个串的哈希值,套用公式$Hash[i]=Hash[i+1]*SEED+(ss[i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4821 字符串题. 现场使用字符串HASH乱搞的. 枚举开头! #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <queue> #include <map> #include <set> #inclu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4821 题目大意:给你M,L两个字母,问你给定字串里不含M个长度为L的两两相同的子串有多少个? 哈希+枚举 我就是不会枚举这样的,这次涨姿势了. 每次枚举起点,然后就能枚举全部的. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <alg…
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in th…
题意: 一个字符串S  问其中有几个子串能满足以下条件: 1.长度为M*L 2.可以被分成M个L长的小串  每个串都不一样 分析: hash方法,一个种子base,打表出nbase[i]表示base的i次方 将以i位字符开头之后的串hash成一个无符号长整型:hash[i]=hash[i+1]*base+str[i]-'a'+1 然后每个L长度的小串的hash值即为:hash[i]-hash[i+L]*nbase[L] map记录hash值的个数 以i位字符开头的字符串与以i+L位字符开头的字符…
题目:Anigram单词 题意:给出词典,再给出一些单词,求单词的Anigram数量. 思路:先将字串转换成哈希表,然后再用map链接. hash表构造方法汇总:http://www.cnblogs.com/gj-Acit/archive/2013/05/06/3062628.html 此题使用除留余数法. #include <iostream> #include <algorithm> #include <stdlib.h> #include <time.h&g…