HDU 1029 Ignatius and the Princess IV (map的使用)
传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=1029
Ignatius and the Princess IV
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Java/Others)
Total Submission(s): 42359 Accepted Submission(s): 18467
"I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to tell me which integer is the special one after I tell you all the integers." feng5166 says.
"But what is the characteristic of the special integer?" Ignatius asks.
"The integer will appear at least (N+1)/2 times. If you can't find the right integer, I will kill the Princess, and you will be my dinner, too. Hahahaha....." feng5166 says.
Can you find the special integer for Ignatius?
1 3 2 3 3
11
1 1 1 1 1 5 5 5 5 5 5
7
1 1 1 1 1 1 1
5
1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 125
int main()
{
LL n;
while(~scanf("%I64d",&n))
{
map<LL,LL> mm;
map<LL,LL>::iterator it;
for(LL i=;i<=n;i++)
{
LL x;
scanf("%I64d",&x);
mm[x]++;
}
for(it=mm.begin();it!=mm.end();it++)
{
if(it->second>=(n+)/)
{
cout<<it->first<<endl;
break;
}
}
}
return ;
}
HDU 1029 Ignatius and the Princess IV (map的使用)的更多相关文章
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)
HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...
- hdu 1029 Ignatius ans the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- [ACM] hdu 1029 Ignatius and the Princess IV (动归或hash)
Ignatius and the Princess IV Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32767K (Ja ...
- HDU 1029 Ignatius and the Princess IV (动态规划、思维)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- HDOJ/HDU 1029 Ignatius and the Princess IV(简单DP,排序)
此题无法用JavaAC,不相信的可以去HD1029题试下! Problem Description "OK, you are not too bad, em- But you can nev ...
- HDU 1029 Ignatius and the Princess IV DP
kuangbin 专题 这题,有很多种解法. 第一种: 直接比较每个数出现次数. #include<iostream> #include<string> #include< ...
- HDU 1029 Ignatius and the Princess IV(数论)
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(~scanf("%d",& ...
- HDU 1029 Ignatius and the Princess IV
解题报告: 题目大意:就是要求输入的N个数里面出现的次数最多的数是哪一个,水题.暴力可过,定义一个一位数组,先用memset函数初始化,然后每次输入一个数就将下标对应的上标对应的那个数加一,最后将整个 ...
随机推荐
- springboot aop使用介绍
第一步:添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId&g ...
- POJ 2923(状态集合背包)
http://www.cnblogs.com/kuangbin/archive/2012/09/14/2685430.html #include <iostream> #include & ...
- MySQL root 密码修改
小伙伴要在以前的服务器上装个代码版本控制的软件,要用到数据库,可是想来找去root密码还是忘了,其他已经安装的服务都是用的专用账户配置文件里要找不到root用户的密码.用以下方法将密码强制修改掉: 1 ...
- type="button"和type="submit"的区别
type="button" ,"submit" 的区别(转) Submit是专门用于提交表单的Button,与Button的区别主要有两点: type=button 就单纯是按钮功能 type=s ...
- Docker网络管理机制实例解析+创建自己Docker网络
实例解析Docker网络管理机制(bridge network,overlay network),介绍Docker默认的网络方式,并创建自己的网络桥接方式,将开发的容器添加至自己新建的网络,提高Doc ...
- ArcGIS软件操作——地图配准
初次写博文,出现措词不当.表述不明确等之类的问题,敬请见谅,但会努力做好.同时,也欢迎各位提出意见,共同交流,共同进步! 直奔主题——运用ArcGIS软件对地图进行配准! 1 数据准备:网络下载的中国 ...
- 【Android】Warning :uninstalling will remove the application data!
最近从Android Studio向手机发布项目过程中经常出现, 问题虽小,但是开发过程中确实浪费时间. It is possible that issue is resolved by uninst ...
- Jmeter参数化设置,多用户登录
一.模拟多用户登录场景 如登录模式如下图所示,登录界面中需要输入:用户名.密码.验证码 用户名以及密码均是固定值,不需要做处理.验证码需要处理一下,可以后台配置成固定值,具体可以找开发咨询. 在此场景 ...
- C++中long是什么类型
long long本质上还是整型,只不过是一种超长的整型. int型:32位整型,取值范围为-2^31 ~ (2^31 - 1) .long:在32位系统是32位整型,取值范围为-2^31 ~ (2^ ...
- 微软智能云Azure – 中国首家官方支持CoreOS的公有云
北京2016年6月24日, 在由中国开源软件推进联盟(COPU)主办, 开源社协办,微软赞助的“第十一届开源中国开源世界高峰论坛”上,微软亚太研发集团云计算高级总监梁戈碧女士正式对外宣布一个令人振奋的 ...