怒刷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(也可以用数组)记录每个数出 ...
随机推荐
- PLSA中的EM算法
转自:http://www.cnblogs.com/rocketfan/archive/2011/07/03/2096953.html 主要记录下几个文章博客内容 A Note on EM Algor ...
- Castle IOC容器内幕故事(上)
主要内容 1.WindsorContainer分析 2.MicroKernel分析 3.注册组件流程 一.WindsorContainer分析 WindsorContainer是Castle的IOC容 ...
- C++ 中 int,char*,string,CString之间相互转换-整理
<多字符集下> #include <string> //使用C++标准库的string类时, 定义时 std::string str; using namespace std; ...
- zookeeper的安装和启动
最近的手上一个项目要用到dubbo,顺便研究下zookeeper 1.下载 下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/,下载解压到D:\t ...
- js url图片转bese64
function convertImgToDataURLviaCanvas(url, callback, outputFormat){ var img = new Image(); img.cross ...
- Mailbox and Mail
#ifndef __MAILBOX_H__ #define __MAILBOX_H__ #include <stdint.h> #include <stdlib.h> #inc ...
- WSB备份到远程共享文件夹的限制
WSB备份存储类型: 远程共享文件夹: 可以将一次性(临时)备份和计划备份存储在远程共享文件夹上.(将计划备份存储在远程共享文件夹上的功能是 Windows Server 2008 R2 的新增功能. ...
- 标准C++中的STL容器类简单介绍
SGI -- Silicon Graphics[Computer System] Inc.硅图[计算机系统]公司. STL -- Standard Template Library 标准模板库. ...
- 从客户端(&)中检测到有潜在危险的 Request.Path 值解决方案
出这个问题基本上是在转址字符串中有非法字符“<”,'&'之类的. 方案1: 如果仅仅只是转换页面,传参时出现的问题,可对数据加密: 绑定数据传值时加密 <%#Server.UrlE ...
- 关于phpcmsv9更新缓存出现链接被重置的问题
今天安装phpcmsv9后更新缓存出现链接被重置的错误,..找了半天原因. . .原来是apache配置里面的keepAlive显示的是off,,应该将其改为on...然后重新启动apache....