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

本文共 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

你可能感兴趣的文章
【300】◀▶ IDL - ENVI API
查看>>
Docker初体验
查看>>
UBUNTU LINUX中连接ANDROID 小米真机调试
查看>>
[转] Zend Framework 中 htaccess 的标准配置
查看>>
linux就是这个范儿之融于心而表于行(1)
查看>>
maven安装配置部署建项运行
查看>>
node爬虫
查看>>
接口测试之JMeter初探
查看>>
Docker背后的内核知识——cgroups资源限制(转)
查看>>
Java技术——Java泛型详解(转)
查看>>
某个第三方支付平台数据库的分析、学习与总结(转)
查看>>
Linux Linux程序练习八
查看>>
读书笔记:《写给大家看的设计书》
查看>>
Predicate与filter
查看>>
UITableViewCell 取消分隔线
查看>>
性能测试工具 nGrinder 项目剖析及二次开发
查看>>
Mybatis集成pagehelper and jsqlparser(分页)
查看>>
50+ 顶级开源 Kubernetes 工具列表
查看>>
老年夫妇为何分床睡?83岁的奶奶是这样说的……
查看>>
恶意软件日均进攻百万次!三大方法保护Hadoop集群免遭攻击!
查看>>