HDU 1004 Let the Balloon Rise(STL初体验之map)
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
题目大意:如题
思路:创建一个map<string, int>, 通过cnt["string"]=int的方法储存值,学习其中关于“找a是否存在,不存在就先让它为0,再加1,存在就直接加一”
代码如下
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<stdlib.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e5 + 100;
double eps = 1e-8;
map<string, int> cnt;
int main(){
int n;
while(scanf("%d", &n) && n){
cnt.clear();
string a;
int ans =0;
string anss;
for(int i = 0; i < n ; i++){
cin >> a;
if(!cnt.count(a))cnt[a]=0;
cnt[a]++;
if(cnt[a]>ans){
ans =cnt[a];
anss = a;
}
}
cout << anss << endl;
}
return 0;
}
HDU 1004 Let the Balloon Rise(STL初体验之map)的更多相关文章
- hdu 1004 Let the Balloon Rise(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise(map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise【STL<map>】
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU 1004 Let the Balloon Rise map
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise strcmp、map、trie树
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...
- HDU 1004 - Let the Balloon Rise(map 用法样例)
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- HDU 1004 Let the Balloon Rise(map应用)
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
随机推荐
- RabbitMQ安装(Windows)
一.下载安装 由于RabbitMQ是用Erlang语言编写的,因此需要先安装Erlang. 通过http://www.erlang.org/downloads获取对应安装文件进行安装 增加环境变量ER ...
- 小白学Java:包装类
目录 小白学Java:包装类 包装类的继承关系 创建包装类实例 自动装箱与拆箱 自动装箱 自动拆箱 包装类型的比较 "=="比较 equals比较 自动装箱与拆箱引发的弊端 自动装 ...
- python之嵌套函数调用
#定义嵌套函数 def func1(): print('this is func1') def func2(): print('this is func2')#调用1func1()输出:this is ...
- Neo4j集群容器化部署
集群基本配置(示例) core servers: 10.110.10.11, 10.110.10.12, 10.110.10.13read replicas: 10.110.10.14, 10.110 ...
- 写了个 Task.WhenAll(t)的一个例子。
public static void Main() { var t = Task.Run(() => { throw new Exception("aa"); }); Tas ...
- P3802 小魔女帕琪 概率与期望
P3802 小魔女帕琪 题目背景 从前有一个聪明的小魔女帕琪,兴趣是狩猎吸血鬼. 帕琪能熟练使用七种属性(金.木.水.火.土.日.月)的魔法,除了能使用这么多种属性魔法外,她还能将两种以上属性组合,从 ...
- cogs 3008. 朋友圈
3008. 朋友圈 ★★ 输入文件:friendscircle.in 输出文件:friendscircle.out 简单对比时间限制:1 s 内存限制:256 MB [题目描述] NO ...
- uni-app,vue,react,Trao之缓存类封装
uni-app,vue,react,Trao之缓存类封装 一,介绍与需求 1.1,介绍 缓存主要分为如下几个 1.LocalStorage LocalStorage是永久性的本地缓存,存储在客户端的浏 ...
- struts2学习第一天
Stuts2是基于MVC设计模式成熟的Web应用框架.不仅仅是Struts1的下一个版本,是一个全新的Struts架构.由WebWork社区跟Strut社区联手打造的.(教程来自W3Cschool) ...
- minikube 设置CPU和内存
安装minikube之后,第一次sudo minikube start 时,设置参数--cpus int --memory int . 如果需要更改设置,需要将缓存文件$HOME/.minikube ...