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
 
 
 
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. int s[];
  5. int main()
  6. {
  7. int n;
  8. while(cin>>n){
  9. int j,max,a,t;
  10. memset(s,,sizeof(s));
  11. for(int i=;i<n;i++){
  12. cin>>a;
  13. s[a]++;
  14. if(s[a]==(n+)/){
  15. t=a;
  16. }
  17. }
  18. cout<<t<<endl;
  19. }
  20. //system("pause");
  21. return ;
  22. }

K - Ignatius and the Princess IV的更多相关文章

  1. hdu 1029 Ignatius ans the Princess IV

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

  2. Ignatius and the Princess IV

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

  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 Ignatius and the Princess IV (map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 Ignatius and the Princess IV Time Limit: 2000/10 ...

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

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

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

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

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

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

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

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

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

随机推荐

  1. C语言结构体的字节对齐

    Test Code: #include <iostream> #include <cstring> using namespace std; struct A{ int a; ...

  2. hdu5347 MZL's chemistry(打表)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud MZL's chemistry Time Limit: 2000/1000 MS ...

  3. C++ 使用cl命令编辑时发生的问题收录

    1.cl不是内部或这外部命令,也不是可运行的程序或批处理文件. 这个问题的出现的原因是因为系统找不到cl命令处理程序,无法识别,解决办法: 首先在C盘查找cl.exe,可能会查到多个,先选择第一个,将 ...

  4. Mvc htmlhelper that generates a menu from a controller

    Simple menu system that grabs a list of actions from a single controller and creates an unordered li ...

  5. Largest Rectangle in a Histogram(HDU 1506 动态规划)

    Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. Scala学习笔记--List、ListBuffer

    ListBuffer(列表缓冲) ListBuffer类位于  scala.collection.mutable.ListBuffer val buf = new ListBuffer[Int] va ...

  7. Block(二)内存管理与其他特性

    一.block放在哪里 我们针对不同情况来讨论block的存放位置: 1.栈和堆 以下情况中的block位于堆中: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

  8. [Ioi2007]Miners 矿工配餐(BZOJ1806)

    [Ioi2007]Miners 矿工配餐 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 214  Solved: 128 Description 现有两 ...

  9. IC封装图片认识(二):SOP&SOJ

    SOP SOP-EIAJ-TYPE-II-14L SSOP SSOP-16L TSOP(Thin Small Outline Package) TSSOP(Thin Shrink Outline Pa ...

  10. Ubuntu下配置NFS服务

    Table of Contents 1.下载相关软件 2.建立共享目录 3.修改该配置文件 4.重启服务 5.测试服务器 6.测试客户端 测试系统:Ubuntu8.04 1.下载相关软件 使用如下命令 ...