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 ...
随机推荐
- (二)unittst用例操作
一.跳过用例 @unittest.skip(reason) 跳过被此装饰器装饰的测试. reason 为测试被跳过的原因. 应用场景: 1,有些用例不需要再次执行,或者作废的用例 2,本次测试构建,不 ...
- 你真的看懂Android事件分发了吗?
引子 Android事件分发其实是老生常谈了,但是说实话,我觉得很多人都只是懂其大概,模棱两可.本文的目的就是再次从源码层次梳理一下,重点放在ViewGroup的dispatchTouchEvent方 ...
- ACM北大暑期课培训第八天
今天学了有流量下界的网络最大流,最小费用最大流,计算几何. 有流量下界的网络最大流 如果流网络中每条边e对应两个数字B(e)和C(e), 分别表示该边上的流量至少要是B(e),最多 C(e),那么,在 ...
- JWT (一):认识 JSON Web Token
JWT(一):认识 JSON WebToken JWT(二):使用 Java 实现 JWT 什么是 JWT? JSON Web Token(JWT)是一种开放标准(RFC 7519),它定义了一种紧凑 ...
- 小程序和wepy做循环渲染如何点击拿到相对应的值
数据和其他的就忽略,简单上手,wepy的for渲染方式改成对应的就行,传参触发不用改 <view wx:for="{{list}}"> {{item.title}} & ...
- mysql索引创建和使用细节
最近困扰自己很久的膝盖积液手术终于做完,在家养伤,逛技术博客看到easyswoole开发组成员仙士可博客有关mysql索引方面的知识,自己打算重温下. 正常业务起步数据表数据量较少,不用考虑使用索引, ...
- 架构师JavaScript 的对象继承方式,有几种程序写法?
架构师JavaScript 的对象继承方式,有几种程序写法? 一.对象冒充 其原理如下:构造函数使用 this 关键字给所有属性和方法赋值(即采用类声明的构造函数方式).因为构造函数只是一个函数, ...
- @Controller和@RestController
@RestController=@Controller+@ResponseBody 1.使用RestController时,返回到前端的内容是Return里的内容,无法返回jsp/html等页面, 此 ...
- ORM Q查询
表达式: Book.objects.filter(Q(pk=1)|(Q(user_id=1)& Q(room_id=1))) 方法: q=Q() q.connector="OR&qu ...
- PHP——数组
数组的定义 数组能够在单个变量中存储多个值. 创建空数组: $arr = array();//表示创建一个空数组,并把创建的空数组赋值给变量$arr 数值数组 自动分配 ID 键(ID 键总是从 0 ...