[poj1200]Crazy Search(hash)】的更多相关文章

Crazy Search Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26713 Accepted: 7449 Description Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given…
                                                    Crazy Search 真是不容易啊,人生第一道hash题竟然是搜博客看题解来的. 题意:给你一个包含m种字符的字符串,求长度为n的不同子串有多少个. 将每个字串化为一个具体的数然后存入数组标记即可,如果重复出现肯定不用再加了.那么怎么化为一个数呢,这里用的方法是先将每个字符对应一个数,然后每个长度为n的子串就有了一个连续的数,将这个数段转化为m进制下的数即可,时间复杂度是O(len).注意…
Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Description Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number…
题目链接:http://poj.org/problem?id=1200 思路分析:从数据来看,该题目使用线性时间算法,可见子串的比较是不可能的:使用hash可以在常数时间内查找,可以常数时间内判重, 可以再线性时间内解决问题:问题关键在与Hash函数的选择,使得子串之间的Hash值不同:由于NC的提示,使用NC作为基数,其他字符 分配不同的数码,从1-NC,再求取Hash值,保证函数为单一映射: 代码如下: #include <stdio.h> #include <string.h>…
题目意思: 给出一个字符串和字串的长度,求出该字符串的全部给定长度的字串的个数(不同样). 题目分析: 此题为简单的字符串哈hash map问题,能够直接调用STL里的map类. map<string,int> snum; AC代码: #include<iostream> #include<string> #include<map> using namespace std; int main() { int t,n,nc; cin>>t; whi…
A - Crazy Search Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number of different substrings of a given size that exist…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1381 Crazy Search Description Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be t…
Crazy Search Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3035    Accepted Submission(s): 1133     Problem Description Many people like to solve hard puzzles some of which may lead them to…
Crazy Search Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 32483   Accepted: 8947 Description Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a gi…
Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number of different substrings of a given size that exist in the text. As…