Ignatius and the Princess IV
Ignatius and the Princess IV
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Java/Others)
Total Submission(s): 13294 Accepted Submission(s): 5362
"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?
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
5
1
#include<stdio.h>
#include<string.h>
int a[];
int main()
{
int n,i,j,max;
while(~scanf("%d\n",&n))
{
memset(a,,sizeof(a));
for(i =;i < n;i ++)
{
scanf("%d",&j);
a[j]++;
if(a[j]>=(n+)/)
max = j;
}
printf("%d\n",max);
}
return;
}
Ignatius and the Princess IV的更多相关文章
- hdu 1029 Ignatius ans the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- Ignatius and the Princess IV(乱搞一发竟然过了)
B - Ignatius and the Princess IV Time Limit:1000MS Memory Limit:32767KB 64bit IO Format:%I64 ...
- 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 ...
- (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 ...
- 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 ...
- HDOJ.1029 Ignatius and the Princess IV(map)
Ignatius and the Princess IV 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出一个奇数n,下面有n个数,找出下面数字中出现次数大于(n+1)/2的数字,并输出. ...
- kuangbin专题十二 HDU1029 Ignatius and the Princess IV (水题)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- [ACM] hdu 1029 Ignatius and the Princess IV (动归或hash)
Ignatius and the Princess IV Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32767K (Ja ...
随机推荐
- linux ptheard 生产者消费者
; { { printf( pthread_mutex_lock(&mutex); != g_iBufSiz ...
- Android LayoutInflater.inflate使用上的问题解惑
最近在在使用LayoutInflater.inflate方法时遇到了一些问题,以前没有仔细看过此类的使用方法,故将其记录下来,方便日后查阅. 相信大家都知道LayoutInflater.inflate ...
- tq --uboot使用
- Nand Flash命令- nand info nand erase nand read[.jffs2] addr off size .jffs代表ECC方式不同 nan ...
- couchDB入门
无意翻到一本新书<CouchDB权威指南> 发现这就是传说中的NoSQL,看排第一的是mangodb,redis有些人说是,有些人说不是. CouchDB的开发很天才,直接可以通过java ...
- 将选择的图片显示在listview中,并显示filename,path和type
if (openFileDialog1.ShowDialog() == DialogResult.OK) { listView1.Items.Clear(); string[] files = ope ...
- webp介绍与使用
webp是谷歌10年发布的一种新的图片格式,支持有损压缩或无损压缩.据官方称无损压缩的webp在体积上要比png小26%,而有损压缩要比同质量jpg小25%~34%.经本人测试,由腾讯智图处理 ...
- AppDomain(1)-AppDomainSetup
- Java笔记1 : 在生产者消费者模式中,线程通信与共享数据,死锁问题与解决办法
本例定义了4个类,这里说一下,方便下面讲解.分别是Product(产品),Producer(生产者),Consumer(消费者), Test(测试类). 多线程之间通信与共享数据只要引用同一内存区域就 ...
- QT窗口渐现效果,窗口震动效果,鼠标移动窗口
//窗口渐现效果void MainWindow::closeWindowAnimation() //关闭窗口效果 { QPropertyAnimation *animation = new QProp ...
- Pentaho Data Integration (三) Pan
官网连接: http://wiki.pentaho.com/display/EAI/Pan+User+Documentation Pan Pan 是一个可以执行使用Spoon编辑的transforma ...