#include<iostream>
#include<string.h>
using namespace std; int main()
{
int n,i;
int t;
int cnt;
int result;
while(scanf("%d",&n)!=EOF)
{
cnt=0;
for(i=0;i<n;i++)
{
scanf("%d",&t); if(cnt==0)
{
cnt=1;
result=t;
}
else
{
if(t==result)cnt++;
else cnt--;
} }
printf("%d\n",result);
}
return 0;
}

hdu1029的更多相关文章

  1. HDU1029时钟(排序)

    题意:是用两个指针的一个模拟时钟的时针和分针.两个指针形成一个角度.角度测量两个指针之间的最小角度.两只手之间的角度是大于或等于0,且小于或等于180度的度量.由于一个序列的五个不同的写入时间,格式为 ...

  2. HDU1029 Ignatius and the Princess IV (水题)

    <题目链接> 题目大意:给你一段序列,问你在这个序列中出现次数至少为 (n+1)/2 的数是哪个. 解题分析: 本题是一道水题,如果用map来做的话,就非常简单,但是另一个做法还比较巧妙. ...

  3. (Arrays.sort() 或 map) Ignatius and the Princess IV hdu1029

    Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csd ...

  4. hdu--1029 编程之美 在数组a中 (元素个数n n是奇数)找一个数字 它出现的次数大于(n+1)/2

    我为什么总是犯这些愚蠢错误啊,还是自己逻辑不够严谨. 努力ing...... #include <iostream> #include <cstdio> #include &l ...

  5. HDU1029(KB12-B)

    Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K ( ...

  6. kuangbin专题十二 HDU1029 Ignatius and the Princess IV (水题)

    Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K ( ...

  7. HDU1029 - Ignatius and the Princess IV【水题】

    给你n个数字,请你找出出现至少(n+1)/2次的数字. 输入 本题包含多组数据,请处理到EOF: 每组数据包含两行. 第一行一个数字N(1<=N<=999999) ,保证N为奇数. 第二行 ...

  8. HDU1029 简单DP

    "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. &quo ...

  9. [HDU1029]Ignatius and the Princess IV<桶 水题>

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 题目大意: 多组数据,每组数据先给一个n,然后给n各数字,找出n各数字中出现了至少(n+1)/2 ...

随机推荐

  1. Leetcode:Minimus Depth of Binary Tree

    The problem description: Given a binary tree, find its minimum depth. The minimum depth is the numbe ...

  2. ibatis-Spring 整合

    这两天一直在研究ibatis与spring的整合 一个小小的demo搞的我头晕目眩的,但程序一旦跑起来了,突然有一种豁然开朗,重见天日,感觉生活很美好的感觉!,也许,这就是那一行行的代码带给我们的不同 ...

  3. 创建 Mac OS X 10.9 USB 安装盘

    通过 App Store 下载最新的 OS X 10.9 在“应用程序”目录找到下载的 OS X 10.9 安装文件,选中并鼠标右键,菜单中选择“显示包内容” 弹出的 Finder 中进入 Conte ...

  4. JAXP进行DOM和SAX解析

    1.常用XML的解析方式:DOM和SAX 1)DOM思想:将整个XML加载内存中,形成文档对象,所以对XML操作都对内存中文档对象进行. 2)SAX思想:一边解析,一边处理,一边释放内存资源---不允 ...

  5. Thrift RPC实战(二) Thrift 网络服务模型

    限于篇幅关系,在观察源码的时候,只列举了部分源代码 TServer类层次体系 TSimpleServer/TThreadPoolServer是阻塞服务模型 TNonblockingServer/THs ...

  6. poj 3181 Dollar Dayz(求组成方案的背包+大数)

    可能nyist看见加的背包专题我老去凑热闹,觉得太便宜我了.他们新加的搜索专题居然有密码. 都是兄弟院校嘛!何必那么小气. 回到正题,跟我写的上一篇关于求组成方案的背包思路基本一样,无非就是一个二维费 ...

  7. TCP中ECN的工作原理分析二(摘自:RFC3168)

    英文源:http://www.icir.org/floyd/ecn.html 发送端和接收端处理: The TCP Sender For a TCP connection using ECN, new ...

  8. C语言面试题汇总

    1.   阅读下面程序并写出输出结果(10分). main() { int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d, ...

  9. mysqldump备份错误:诡异的#mysql50#.mozilla数据库

    今天测试mysql自动备份功能 在red_hat_linux5系统下安装了mysql_5.5 系统提示执行脚本抛错, 手动执行脚本, 返回错误:mysqldump: Got error: 1102: ...

  10. vps使用(centos)

    javaweb开发,vps来做个人测试 首先配置vps(centos) 1.安装javeweb环境 用ssh远程服务器后,中文乱码,因为ssh的字符集和服务器的字符集不一致,服务器是utf-8,可以通 ...