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 ...
随机推荐
- 存读Blob Oracle
- asp.net Form 认证【转】
第一部分 如何运用 Form 表单认证 一. 新建一个测试项目 为了更好说明,有必要新建一个测试项目(暂且为“FormTest”吧),包含三张页面足矣(Default.aspx.Logi ...
- app服务器
http://heipark.iteye.com/blog/1847421http://heipark.iteye.com/blog/1847421http://wenku.baidu.com/vie ...
- java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
Myeclipse 8.6使用tomcat7时间.执行javaweb如报告了以下错误项: java.lang.NoClassDefFoundError: org/apache/juli/logging ...
- winzip15.0许可证
username:Juzhaofeng 授权码:MPZRP-Y7LWW-K1DKG-FM92E-2C5F5-ZEKFF
- C++ - Identifier not found
This is because forward declaration in C++: Compiler needs to know function prototype when functi ...
- 添加xml文件编辑语法提示
找到Struts的lib目录 找到struts2-core-文件并解压开 这个struts.dtd文件才是我们需要添加的文件 双击XML Catalog 点击ADD Key中复制粘贴D:\web\st ...
- 变化App.config其中值,并保存
using System; using System.Collections.Generic; using System.Configuration; using System.IO; using S ...
- android 编译调用C代码
博客地址:www.zalezone.cn 前言 需求来源 这几天帮别人做一个简单的androidclient,也没什么功能,主要就是调用C代码来对手机的Wifi网络进行设置.于是也就引出了技术难点所在 ...
- [思考] hdu 4811 Ball
意甲冠军: 有三种颜色的小珠,每种颜色的量R,Y,B 转球进入桌面成序,有多少种不同的颜色分别砍下的球在球门前+有多少身后球不同的颜色 问:最大的总比分值 思考: 球和后面的球先放好.剩下的就放中间了 ...