博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ignatius and the Princess IV (水题)
阅读量:5134 次
发布时间:2019-06-13

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

"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

51 3 2 3 3111 1 1 1 1 5 5 5 5 5 571 1 1 1 1 1 1

Sample Output

351

题解:刷访问量,此题太简单

代码:

#include
#include
#include
#include
using namespace std;int main(){ int n; int dp[100005]={0}; while(scanf("%d",&n)!=EOF) { memset(dp,0,sizeof(dp)); int flag=0; int k; for(int t=0;t
=(n+1)/2) { if(flag==0) printf("%d\n",k); flag=1; } } }}

 

转载于:https://www.cnblogs.com/Staceyacm/p/10781978.html

你可能感兴趣的文章
C++ 实践总结
查看>>
composer 国内镜像配置
查看>>
软件是天时、地利、人和的产物!
查看>>
python定时清空本目录下除本脚本外的全部文件
查看>>
【PHP】在目标字符串指定位置插入字符串
查看>>
【JS】jQuery设置定时器,访问服务器(PHP示例)配合微信、支付宝原生支付,跳转web网页...
查看>>
实验四2
查看>>
VS2012+Win7网站发布详细步骤
查看>>
Android现学现用第十一天
查看>>
Bin Packing 装箱问题——NPH问题的暴力枚举 状压DP
查看>>
多路复用
查看>>
python 列表
查看>>
Python数据可视化之Pygal(雷达图)
查看>>
Django组件--cookie与session
查看>>
12. javacript高级程序设计-DOM2和DOM3
查看>>
Centos7安装vsftpd (FTP服务器)
查看>>
当前主流读取Excel技术对比
查看>>
js-格式化数字保留两位小数-带千分符
查看>>
【Java】forward & redirect 的差异
查看>>
Java学习笔记--字符串和文件IO
查看>>