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 ...
随机推荐
- schedule of 2016-10-09~2016-10-16(Sunday~Sunday)——1st semester of 2nd Grade
most important things to do 1.prepare for toefl 2.joint phd preparations 3.ieee trans thesis to writ ...
- Jmeter+Jenkins 搭配进行接口测试
单纯通过Jmeter的界面进行Web的接口测试,效率低下.为此将Jmeter的接口测试与Jenkins联合,实现持续集成.配置完成后,只需修改运行的Jmeter脚本即可,运行结束后测试结果发送到指定邮 ...
- Android学习进度一
在解决了电脑产生的一系列问题之后成功安装了Android Studio,并在其自带的手机模拟器上成功运行了第一个App(Hello World!),通过这个最简单的App研究了App基本的工程结构,为 ...
- kettle连接oracle数据库报错,ORA-12505
报错信息: Error connecting to database: (using class oracle.jdbc.driver.OracleDriver) Listener refused t ...
- 完美解决win10系统无法安装.NET Framework问题
今天在安装willow插件的时候系统提示需要安装.NET Framework3.5的问题,当点击系统自动解决的时候,Windows系统又会提示错误,其实这也见怪不怪了,如果能自动解决的话也不会出现这种 ...
- Android栈溢出漏洞利用练习
在Github上看到一个Linux系统上的栈溢出漏洞利用练习项目: easy-linux-pwn.在原项目基础上,我稍微做了一些改动,将这个项目移植到了Android 9.0系统上: easy-and ...
- 真机调试报The executable was signed with invalid entitlements.错误
真机运行时,提示The executable was signed with invalid entitlements.(The entitlements specified in your appl ...
- Qt Installer Framework翻译(3-2)
添加组件 如果用户在初始安装期间未选择所有可安装组件,则后续也可以使用包管理器从仓库中获取剩余组件进行安装.包管理器是维护工具的一部分,该维护工具在初始安装过程中与应用程序一起被安装.仅当包含组件的仓 ...
- python专题文件操作
一 前言 本篇文章主要对文件操作进行说明,知识追寻者创作必属精品,读完本篇你将获得基础的文件操作能力,深入理解文件操作API,基础真的很重要,不管学什么知识,故看知识追寻者的专题系列真的很不错. 二 ...
- 获取各类前几名数据的MYSQL写法
前几天,某在培训的朋友问我一个问题:查询每门功课成绩最好的前两名该怎么写. 这个问题虽然听起来挺简单,但是很有意思,于是我就新建了一张如下的表: stuNo为学号,stuScore为分数,course ...