怒刷DP之 HDU 1029
Time Limit:1000MS Memory Limit:32767KB 64bit IO Format:%I64d & %I64u
jehad (2014-05-27)
gscsdlz (2015-04-14)
System Crawler (2015-09-05)
Description
"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?
Input
Output
Sample Input
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
Sample Output
5
1
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
using namespace std; int main(void)
{
int n,box,count,max; while(scanf("%d",&n) != EOF)
{
count = ;
while(n --)
{
scanf("%d",&box); if(!count)
{
max = box;
count ++;
}
else
if(max == box)
count ++;
else
count --;
}
printf("%d\n",max);
} return ;
}
怒刷DP之 HDU 1029的更多相关文章
- 怒刷DP之 HDU 1257
最少拦截系统 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 怒刷DP之 HDU 1160
FatMouse's Speed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- 怒刷DP之 HDU 1260
Tickets Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- 怒刷DP之 HDU 1176
免费馅饼 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- 怒刷DP之 HDU 1087
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- 怒刷DP之 HDU 1114
Piggy-Bank Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit S ...
- 怒刷DP之 HDU 1069
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- 怒刷DP之 HDU 1024
Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
随机推荐
- Python之函数进阶
本节内容 上一篇中介绍了Python中函数的定义.函数的调用.函数的参数以及变量的作用域等内容,现在来说下函数的一些高级特性: 递归函数 嵌套函数与闭包 匿名函数 高阶函数 内置函数 总结 一.递归函 ...
- [置顶] Android AlarmManager实现不间断轮询服务
在消息的获取上是选择轮询还是推送得根据实际的业务需要来技术选型,例如对消息实时性比较高的需求,比如微博新通知或新闻等那就最好是用推送了.但如果只是一般的消息检测比如更新检查,可能是半个小时或一个小时一 ...
- lvs-dr模式原理详解和可能存在的“假负载均衡”
原文地址: http://blog.csdn.net/lengzijian/article/details/8089661 lvs-dr模式原理 转载注明出处:http://blog.csdn.net ...
- Android Studio Push rejected: Push to origin/Alpha1.0 was rejected
android studio git 右键项目, git pull 刷新选择Alpha1.0同步后,再commit and push
- linux的webserver配置与管理——创建用户个人主页
本实验用的是RedHat linux9.0,在虚拟机上进行操作,它已具有相当完好的可视化界面,这样用户会更加easy接受和理解. 首先呢就是虚拟机的相关配置,这个就不说了,当我们安装完系统后,打开终端 ...
- Pre-compile (pre-JIT) your assembly on the fly, or trigger JIT compilation ahead-of-time (转)
Introduction All .NET developers know that one of the best features of the CLR is JIT-compilation: J ...
- [转]Swift Cheat Sheet
原文:http://kpbp.github.io/swiftcheatsheet/ A quick cheat sheet and reference guide for Apple's Swift ...
- 在C#中使用全局鼠标、键盘Hook
今天,有个同事问我,怎样在C#中使用全局钩子?以前写的全局钩子都是用unmanaged C或C++写个DLL来实现,可大家都知道,C#是基于.Net Framework的,是managed,怎么实现全 ...
- progressBarButton
https://github.com/longtaoge/progressBarButton
- .net 调用C++类库
事实上这一直是个非常无解的问题.最好的办法是将C++类库写成COM. 可是有时候往往不能这个做.那就仅仅有两种办法:转成C函数形式或者Manage C++封装. 下文就介绍了这两种方法. 原帖:htt ...