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 ...
随机推荐
- Linux中du、df显示不一致问题
Linux中du.df显示不一致问题 最近在做关于Q博士的项目的时候,用到了docker进行部署,对于后端服务可能会经常变动,于是将docker容器的jar包与宿主机目录下的jar包进行绑定,之后每次 ...
- 我该如何学习spring源码以及解析bean定义的注册
如何学习spring源码 前言 本文属于spring源码解析的系列文章之一,文章主要是介绍如何学习spring的源码,希望能够最大限度的帮助到有需要的人.文章总体难度不大,但比较繁重,学习时一定要耐住 ...
- 轻量级开源小程序SDK发车啦
Magicodes.WxMiniProgram.Sdk 轻量级微信小程序SDK,支持.NET Framework以及.NET Core.目前已提供Abp模块的封装,支持开箱即用. Nuget 新的包 ...
- express框架中使用nodemon自启动服务
1.安装nodemon //全局安装 npm install -g nodemon //本地安装 npm install nodemon --save 2.修改package.json配置 " ...
- .Net Core Web Api实践(四)填坑连接Redis时Timeout performing EVAL
前言:前两篇文章.net core+Redis+IIS+nginx实现Session共享中,介绍了使用Microsoft.Extensions.Caching.Redis实现Session共享的方法, ...
- 使用git将本地文件提交到github存储库
1.首先你要安装git https://git-for-windows.github.io/ 去官网自行下载对应版本 2.安装好git服务器后,找到你项目的文件夹,右键git bash here打开命 ...
- Pycharm 中的翻译工具
对于开发来说,大多数哥们英文欠缺,比如在下,我们大多数使用的开发工具是IDEA,IDEA 很强大,开发起来顺手. 废话不多说,让我们看一下如何使用翻译器. 打开Pycharm 的setting 设置, ...
- php代码没解析成功
在Apache中加载PHP模块 1.打开Apache的配置文件httpd.conf(位于Apache2\conf 目录下). 2.查找 “#LoadModule ssl_module modules/ ...
- ii
char a[10], b[10], c[10], d[10],e[10],f[10],g[10],h[10]; scanf("%s %s %s %s", a, b, c, d); ...
- 解决python爬虫requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX', port=443)问题
爬虫时报错如下: requests.exceptions.SSLError: HTTPSConnectionPool(host='某某某网站', port=443): Max retries exce ...