Ignatius and the Princess IV

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)
Total Submission(s): 30040    Accepted Submission(s): 12812

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
 

Author

Ignatius.L
 
排序输出第n/2个。
 //2017-03-14
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int N = 1e6;
int arr[N]; int main()
{
int n;
while(scanf("%d", &n)!=EOF)
{
for(int i = ; i < n; i++)
scanf("%d", &arr[i]);
sort(arr, arr+n);
printf("%d\n", arr[n/]);
} return ;
}

HDU1029(KB12-B)的更多相关文章

  1. HDU1029时钟(排序)

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

  2. hdu1029

    #include<iostream>#include<string.h>using namespace std;int main(){ int n,i; int t; int ...

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

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

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

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

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

  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. shapefile的使用和地理信息的获得

    Shapefile文件是美国ESRI公司发布的文件格式,因其ArcGIS软件的推广而得到了普遍的使用,是现在GIS领域使用最为广泛的矢量数据格式.官方称Shapefile是一种用于存储地理要素的几何位 ...

  2. MySQL 中文字符集排序

    SELECT 字段名 FROM 表 ORDER BY CONVERT(字段名 USING gbk) ASC;

  3. Freemarker实例教程

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本人声明.否则将追究法律责任.作者:永恒の_☆ 地址:http://blog.csdn.net/chenghui0317/a ...

  4. (转)Java并发编程:线程池的使用方法

    http://www.cnblogs.com/dolphin0520/p/3932921.html http://www.journaldev.com/1069/java-thread-pool-ex ...

  5. js变量提升

    JavaScript的函数定义有个特点,它会先扫描整个函数体的语句,把所有申明的变量“提升”到函数顶部: 'use strict'; function foo() { var x = 'Hello, ...

  6. Math.log()对数的妙用

    ###对数log 的妙用... formatBytes(bytes) { if (bytes === '0' || isNaN(bytes)) return ''; var s = ['Bytes', ...

  7. Python numpy 中 keepdims 的含义

    keepdims主要用于保持矩阵的二维特性 import numpy as np a = np.array([[1,2],[3,4]]) # 按行相加,并且保持其二维特性 print(np.sum(a ...

  8. 启动HDFS之后一直处于安全模式org.apache.hadoop.hdfs.server.namenode.SafeModeException: Log not rolled. Name node is in safe mode.

    一.现象 三台机器 crxy99,crxy98,crxy97(crxy99是NameNode+DataNode,crxy98和crxy97是DataNode) 按正常命令启动HDFS之后,HDFS一直 ...

  9. sftp命令不被识别

    sftp命令不被识别 原因:C:\Windows\System32文件夹下面没有sftp可执行程序 解决方案:安装openssh,安装完成之后可发现在path系统变量的值中多了openssh的安装目录 ...

  10. 全网最详细的CentOS7里如何安装MySQL(得改为替换安装MariaDB)(图文详解)

    不多说,直接上干货! 直接yum install mysql的话会报错,原因在于yum安装库里没有直接可以用的安装包,此时需要用到MariaDB了,MariaDB是MySQL社区开发的分支,也是一个增 ...