HDOJ 4821 String】的更多相关文章

串hash String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 697    Accepted Submission(s): 190 Problem Description Given a string S and two integers L and M, we consider a substring of S as "r…
题目链接: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…
题意:给你一串字符串s,再给你两个数字m l,问你s中可以分出多少个长度为m*l的子串,并且子串分成m个长度为l的串每个都不完全相同 首先使用BKDRHash方法把每个长度为l的子串预处理成一个数字,接着根据题意直接map判重 BKDRHash:一种常用字符串hash,hash简单来说就是把一串字符串通过一些转化成为一个数字,并保证相同字符串转化的数字一样,不相同字符串转化的数字一定不一样.方法就是hash[i]=hash[i-1]*seed(进制)+str[i]-'a'+1(注意要加一,因为不…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4821 题目大意:给你M,L两个字母,问你给定字串里不含M个长度为L的两两相同的子串有多少个? 哈希+枚举 我就是不会枚举这样的,这次涨姿势了. 每次枚举起点,然后就能枚举全部的. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <alg…
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…
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…
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…
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…
后缀数组加二分可解. /* 3553 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorithm&…
http://acm.hdu.edu.cn/showproblem.php?pid=4821 昨晚卡了非常久,開始TLE,然后优化了之后,由于几个地方变量写混.一直狂WA.搞得我昨晚都失眠了,,. 这几次hash军写错的变量--tmp=(j==m-1)?ah[j]:(ah[j]-ah[j-m]*base[m]);  外层循环变量是i,我写的字符串hash的几题都写成tmp=(i==0)? ah[j]:(ah[j]-ah[j-m]*base[m]); 二逼啊 题目大意: 给定一个字符串(最长10^…