hdu1381 Crazy Search(hash map)
题目意思:
给出一个字符串和字串的长度,求出该字符串的全部给定长度的字串的个数(不同样)。
题目分析:
此题为简单的字符串哈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;
while(t--){
string s;
map<string,int> snum;
cin>>n>>nc>>s;
int k=0;
int len=s.length();
for(int i=0;i<=len-n;i++){
string ss=s.substr(i,n);
if(snum[ss]==0){
k++;
snum[ss]=1;
}
}
cout<<k<<endl;
if(t>1) cout<<endl;
}
return 0;
}
hdu1381 Crazy Search(hash map)的更多相关文章
- [poj1200]Crazy Search(hash)
Crazy Search Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26713 Accepted: 7449 Descrip ...
- poj 1200 Crazy Search(hash)
题目链接:http://poj.org/problem?id=1200 思路分析:从数据来看,该题目使用线性时间算法,可见子串的比较是不可能的:使用hash可以在常数时间内查找,可以常数时间内判重, ...
- $Hdu1381\ Crazy\ Search$
前置芝士 :string 的 基本用法 string s = "hello world" ; string tmp(s,0,5) ; cout << tmp <& ...
- (map string)Crazy Search hdu1381
Crazy Search Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- POJ-1200 Crazy Search,人生第一道hash题!
Crazy Search 真是不容易啊,人生第一道hash题竟然是搜博客看题解来的. 题意:给你 ...
- hdu 1381 Crazy Search
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1381 Crazy Search Description Many people like to sol ...
- Hash Map (Hash Table)
Reference: Wiki PrincetonAlgorithm What is Hash Table Hash table (hash map) is a data structure use ...
- POJ 1200:Crazy Search(哈希)
Crazy Search Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32483 Accepted: 8947 Des ...
- POJ1200 A - Crazy Search(哈希)
A - Crazy Search Many people like to solve hard puzzles some of which may lead them to madness. One ...
随机推荐
- cocos2d-x 2.2.3 创建项目的方法
直接复制粘贴到txt文本,然后修改后缀为.bat,然后将bat文件放到tools\project-creator的目录下即可. :project_input @echo 请输入项目名称,按回车,例:H ...
- HDU 1661 Assigments 贪心法题解
Problem Description In a factory, there are N workers to finish two types of tasks (A and B). Each t ...
- Exec l 中分列的作用
- 飘逸的python - 保持命名空间的整洁
API的设计是一个艺术活.往往需要其简单.易懂.整洁.不累赘. 很多时候,我们在底层封装一个方法给高层用,而其它的方法只是为了辅助这个方法的. 也就是说我们只需要暴露这个方法就行,不用关心这个方法是怎 ...
- Oracle改变字段类型
由于需求变化.现在,我们要一个类型NUMBER(8,2)字段类型改变 char. 总体思路如以下: 将要更改类型的字段名改名以备份,然后加入一个与要更改类型的字段名同名的字段(原字段已经改 ...
- tomcat 性能优化(转)
tomcat nginx默许的post大小限制 tomcat nginx默认的post大小限制执行大文件上传,或者,大数据量提交时,当提交的数据大小超过一定限制时,发现后台从request取值的代码r ...
- docker 中国站 www.dockerpool.com 报价图片下载
为了方便一些基本的下载docker 镜像,我建立了一个docker该站 http://www.dockerpool.com 对于Docker用户提供一站式Docker镜像服务: 稳定可靠的官方镜像下载 ...
- T-SQL基础(1) - T-SQL查询和编程基础
第一范式: 第一范式要求表中的行必须是唯一的,属性应该是原子的(atomic).这个范式对于关系的定义来说是冗余的,换句话说,如果一个表真可以表示一个关系,那么它一定符合第一范式. 行的唯一性是可以通 ...
- C#(SuperWebSocket)与websocket通信
原文:C#(SuperWebSocket)与websocket通信 客户端代码 点击可以查看一些关于websocket的介绍 <!DOCTYPE html> <html> &l ...
- Codeforces Round #223 (Div. 2)--A. Sereja and Dima
Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...