首页 > 其他 > 详细

hdu 统计难题(map)

时间:2015-10-13 22:38:49      阅读:221      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251

 

map的强大之处,但是运行时间太长。技术分享

 

代码:

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <ctype.h>
 7 #include <iomanip>
 8 #include <queue>
 9 #include <map>
10 #include <stdlib.h>
11 using namespace std;
12 
13 map<string,int> M;
14 
15 int main(){
16     string x;
17     char a;
18     while(true){
19         scanf("%c",&a);
20         if(a==\n){
21             scanf("%c",&a);
22             x="";   //字符串 x 清空
23         }
24         if(a==\n)break;
25         x+=a;
26         M[x]+=1;
27     }
28     while(cin>>x)
29         printf("%d\n",M[x]);
30     return 0;
31 }

 

hdu 统计难题(map)

原文:http://www.cnblogs.com/wangmengmeng/p/4875789.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!