统计难题

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)

Total Submission(s): 23029 Accepted Submission(s): 9640

Problem Description
Ignatius近期遇到一个难题,老师交给他非常多单词(仅仅有小写字母组成,不会有反复的单词出现),如今老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).
Input
输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每一个提问都是一个字符串.



注意:本题仅仅有一组測试数据,处理到文件结束.
Output
对于每一个提问,给出以该字符串为前缀的单词的数量.
Sample Input
banana
band
bee
absolute
acm ba
b
band
abc
Sample Output
2
3
1
0
Author
Ignatius.L
Recommend
Ignatius.L | We have carefully selected several similar problems for you:

pid=1075" target="_blank">
1075

pid=1247" target="_blank">
1247
1671 1298 1800


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<map>
using namespace std;
map<string,int> u;
int main(){ char s1[20],s2[20],s3[20];
while(gets(s1)){
int len=strlen(s1);
if(len==0) break;
for(int i=0;i<len;++i){
s2[i]=s1[i];
s2[i+1]='\0';
u[s2]++;
}
}
while(gets(s3)){
// printf("##%s\n",s3);
printf("%d\n",u[s3]);
//printf("null\n");
}
return 0;
}

hdoj-1251-统计难题【map】的更多相关文章

  1. hdoj 1251 统计难题 【字典树】

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others) Total Subm ...

  2. hdoj 1251 统计难题(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 思路分析:该问题要求求出以某个字符串为前缀的单词数目,通过使用字典树,在字典树中添加count记 ...

  3. hdu 1251 统计难题 (map水过)

    # include <stdio.h> # include <algorithm> # include <string> # include <map> ...

  4. hdu 1251 统计难题(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    M ...

  5. hduoj 1251 统计难题

    http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  6. HDU 1251 统计难题 (Trie)

    pid=1251">统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/ ...

  7. hdu 1251:统计难题[【trie树】||【map】

    <题目链接> 统计难题                        Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131 ...

  8. HDU 1251 统计难题(Trie模版题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others) Total Subm ...

  9. hdu 1251 统计难题 (字典树入门题)

    /******************************************************* 题目: 统计难题 (hdu 1251) 链接: http://acm.hdu.edu. ...

  10. hdoj 1251 字典树||map

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

随机推荐

  1. hint.css使用说明

    GitHub:http://liu12fei08fei.github.io/html/1hint.html hint.css使用说明 用途 快速实现tooltips提示样式 相关资源 官方网站GitH ...

  2. authentication not supported Connect to TFS Git from Xamarin Studio (non-hosted, locally installed TFS 2013)

    There are several instructions on how to connect to TFS Git from Xamarin Studio if you're using the ...

  3. 取消SVN版本号控制的bash脚本

    原理非常easy,递归删除当前文件夹下全部的 .svn 文件. 把 .svn 换成 .git 就可以用于删除 git 控制

  4. 利用UIWebView获取userAgent需要注意的地方

    网络通信有时候需要传递参数userAgent,iOS中获取userAgent很简单. UIWebView* webView = [[UIWebView alloc] initWithFrame:CGR ...

  5. Action过滤器使用实例(一)

    1.实例一 /// <summary> /// 需要用户登陆的 action,执行提前验证 /// </summary> public class LoginFilterAtt ...

  6. HBase入门基础教程之单机模式与伪分布式模式安装(转)

    原文链接:HBase入门基础教程 在本篇文章中,我们将介绍Hbase的单机模式安装与伪分布式的安装方式,以及通过浏览器查看Hbase的用户界面.搭建HBase伪分布式环境的前提是我们已经搭建好了Had ...

  7. seqgan leakgan

    seqgan https://blog.csdn.net/yinruiyang94/article/details/77675586 leakgan https://www.leiphone.com/ ...

  8. 第一章 EL表达式常见用法

    el最常用的几种使用场景: 从配置文件中读取属性 缺失值情况下,配置默认值 el内部字符串使用String的方法 三目运算符 正则表达式 注入系统属性(system properties) 调用系统原 ...

  9. iOS开发-委托(Delegate)浅谈

    委托其实并不是OC中才有,C#中也有,不过彼此的理解方式是不一样的,OC中委托是协议的一种,需要使用@protocol声明,委托一般在iOS开发中页面中传值用的比较多.委托是Cocoa中最简单.最灵活 ...

  10. 实用的表格内省略号和换行(兼容IE6)

    让连续的英文数字字符换行显示 word-break: break-all; 让单行文字超出的时候使用点点点表示 white-space: nowrap; overflow: hidden; text- ...