博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
怒刷DP之 HDU 1029
阅读量:6124 次
发布时间:2019-06-21

本文共 1928 字,大约阅读时间需要 6 分钟。

Ignatius and the Princess IV
Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64d & %I64u
Submit     
Appoint description: jehad  (2014-05-27)gscsdlz  (2015-04-14)System Crawler  (2015-09-05)

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 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 16 int main(void)17 {18 int n,box,count,max;19 20 while(scanf("%d",&n) != EOF)21 {22 count = 0;23 while(n --)24 {25 scanf("%d",&box);26 27 if(!count)28 {29 max = box;30 count ++;31 }32 else33 if(max == box)34 count ++;35 else36 count --;37 }38 printf("%d\n",max);39 }40 41 return 0;42 }

 

转载于:https://www.cnblogs.com/xz816111/p/4789382.html

你可能感兴趣的文章
rsync 服务器配置过程
查看>>
预处理、const与sizeof相关面试题
查看>>
爬虫豆瓣top250项目-开发文档
查看>>
Elasticsearch增删改查
查看>>
oracle归档日志增长过快处理方法
查看>>
有趣的数学书籍
查看>>
teamviewer 卸载干净
查看>>
多线程设计模式
查看>>
解读自定义UICollectionViewLayout--感动了我自己
查看>>
SqlServer作业指定目标服务器
查看>>
UnrealEngine4.5 BluePrint初始化中遇到编译警告的解决办法
查看>>
User implements HttpSessionBindingListener
查看>>
抽象工厂方法
查看>>
ubuntu apt-get 安装 lnmp
查看>>
焊盘 往同一个方向增加 固定的长度方法 总结
查看>>
eclipse的maven、Scala环境搭建
查看>>
架构师之路(一)- 什么是软件架构
查看>>
jquery的冒泡和默认行为
查看>>
USACO 土地购买
查看>>
【原创】远景能源面试--一面
查看>>