#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
_int64 n,a;
while(scanf("%I64d",&n)!=EOF)
{
_int64 b=,c;
while(n--)
{
scanf("%I64d",&a);
if(b==)
{
c=a;
b++;
}
else
{
if(c==a)
b++;
else
b--;
}
}
printf("%I64d\n",c);
}
return ;
}
Problem Description
"OK, you are not too bad, em... But you can never pass the next test." feng5166 says.
"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
The input contains several test cases. Each test case contains two lines. The first line consists of an odd integer N(1<=N<=999999) which indicate the number of the integers feng5166 will tell our hero. The second line contains the N integers. The input is terminated by the end of file.
 
Output
For each test case, you have to output only one line which contains the special number you have found.
 
Sample Input
5
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
3
5
1
 

动态规划:Ignatius and the Princess IV的更多相关文章

  1. HDU 1029 Ignatius and the Princess IV (动态规划、思维)

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

  2. hdu 1029 Ignatius ans the Princess IV

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

  3. HDU 1029 Ignatius and the Princess IV --- 水题

    HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...

  4. Ignatius and the Princess IV

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

  5. Ignatius and the Princess IV(乱搞一发竟然过了)

    B - Ignatius and the Princess IV Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64 ...

  6. 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 ...

  7. (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 ...

  8. 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/10 ...

  9. HDOJ.1029 Ignatius and the Princess IV(map)

    Ignatius and the Princess IV 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出一个奇数n,下面有n个数,找出下面数字中出现次数大于(n+1)/2的数字,并输出. ...

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

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

随机推荐

  1. 如何使用xftp工具在Windows与Linux之间传输文件

    如何使用xftp工具在Windows与Linux之间传输文件 整理者:vashon 声明:感谢开源社区 xftp工具是一款SFTP,FTP文件传输软件,可在Windows pc与Unix/Linux之 ...

  2. 原生js的容易忽略的相似点(一)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. 在uwp仿IOS的页面切换效果

    有时候我们需要编写一些迎合IOS用户使用习惯的uwp应用,我在这里整理一下仿IOS页面切换效果的代码. 先分析IOS的页面切换.用户使用左右滑动方式进行前进和后退,播放类似于FlipView的切换动画 ...

  4. 详解nginx.conf文件配置项(包括负载均衡)

    http://www.cnblogs.com/hsapphire/archive/2010/04/08/1707109.html #运行用户 user  nobody nobody; #启动进程 wo ...

  5. leetcode_919. Complete Binary Tree Inserter_完全二叉树插入

    https://leetcode.com/problems/complete-binary-tree-inserter/ 给出树节点的定义和完全二叉树插入器类的定义,为这个类补全功能.完全二叉树的定义 ...

  6. Codeforces Round #539 (Div. 2) C. Sasha and a Bit of Relax(前缀异或和)

    转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest ...

  7. finger - 用户信息查找程序

    总览 finger [-lmsp ] [user ... ] [user@host ... ] 描述 The finger 显示关于系统用户的信息 参数: -s Finger 显示用户的登录名, 真名 ...

  8. emacs - GNU Emacs

    总览 (SYNOPSIS) emacs [ command-line switches ] [ files ... ] 描述 (DESCRIPTION) GNU Emacs 是 Emacs 的 一个 ...

  9. 字符串类型:str, bytes 的区别

    Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分. 文本总是 Unicode,由 str 类型表示, 二进制数据则由 bytes 类型表示. Python 3不会以任意隐式的方 ...

  10. python猜年龄游戏升级版

    猜年龄游戏升级版 要求:允许用户最多尝试3次,每尝试3次后,如果还没猜对,就问用户是否还想继续玩,如果回答Y,就继续让其猜3次,以此往复,如果回答N,就退出程序,如何猜对了,就直接退出 age = 1 ...