hdu1251统计难题
来源:互联网 发布:耽美网络剧 编辑:程序博客网 时间:2024/06/03 13:05
统计难题
Problem Description
Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).
Input
输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.
注意:本题只有一组测试数据,处理到文件结束.
Output
对于每个提问,给出以该字符串为前缀的单词的数量.
Sample Input
banana
band
bee
absolute
acm
ba
b
band
abc
Sample Output
2
3
1
0
#include<map>#include<queue>#include<math.h>#include<vector>#include<string>#include<stdio.h>#include<iostream>#include<string.h>#include<algorithm>#define inf 0x3f3f3f#define ll long long#define maxn 110000using namespace std;map<string,int>m;char s[15];int main(){ m.clear(); while(gets(s)) { //cout<<s.size()<<endl; if(strlen(s)==0)break; for(int i=strlen(s);i>=0;i--) { s[i]='\0'; m[s]++; } } while(cin>>s) { cout<<m[s]<<endl; }}
阅读全文
0 0
- 统计难题 hdu1251
- HDU1251统计难题
- 统计难题 hdu1251
- HDU1251-统计难题
- 【统计难题】 hdu1251
- hdu1251统计难题
- hdu1251(统计难题)
- HDU1251:统计难题
- hdu1251统计难题
- HDU1251 统计难题
- hdu1251 统计难题 (Trie)
- hdu1251 统计难题 trie
- HDU1251-统计难题
- hdu1251 统计难题
- hdu1251-统计难题
- Hdu1251 统计难题
- hdu1251统计难题
- C++统计难题hdu1251
- 牛客网初级班(2)
- C#算法系列(7)——快速排序
- [POJ]3525 半平面交
- TinyPng批量压缩Python脚本
- MySql常用命令和语法以及可视化工具Navicat的使用
- hdu1251统计难题
- HEVC编码结构
- Kettle实现行转列1(场景)
- Windows安装Mysql客户端
- Python自然语言处理工具小结
- springMVC分页显示
- java ---list
- 985因子对难题
- centos6.5防火墙配置