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 ...
随机推荐
- 开始学习requirejs+easyui的使用.
开始学习requirejs+easyui的使用. 目录结构: |-project |-easyui01 |-js |-main.js |-index.html |-libs libs目录下放入的是ea ...
- c++primer复习(一)
1 const对象默认为文件的局部变量(P50) a.cpp ; b.cpp extern int a;//undefined reference to "a" a.cpp ; b ...
- Mysql备份数据库的一种方法
今天添加了一个数据库自动备份的模块,mysql数据备份的方法有很多,可以对单个数据库备份,可以多个数据库备份,也可以对某一个表进行备份,可以只备份数据库的结构不备份数据,可以根据需要做不同处理,正好现 ...
- HeadFirst设计模式
oo基础 抽象 封装 多态 继承 oo原则 封装变化 多用组合,少用继承 针对接口编程,不针对实现编程(策略模式) 为交互对象之间的松耦合设计而努力(观察者模式) 对扩展开放,对修改关闭(装饰者模式) ...
- ubuntu 安装phpmyadmin
参考文章: http://www.111cn.net/database/mysql/43957.htm access错误的解决方法 1 首先下载 去官网下载phpmyadmin 2 然后直接 ...
- 【转】Oracle job procedure 存储过程定时任务
原文:Oracle job procedure 存储过程定时任务 oracle job有定时执行的功能,可以在指定的时间点或每天的某个时间点自行执行任务. 一.查询系统中的job,可以查询视图 --相 ...
- PHP对URL设置
一.URL规则 1.默认是区分大小写的 2.如果我们不想区分大小写可以改配置文件 'URL_CASE_INSENSITIVE'=>true, //url不区分 ...
- Vim 中文件目录浏览插件——NERD tree
说明 :vim的插件NERDTree用于使得vim窗口分左右窗口显示的用法说明.其中,左侧为目录的树形界面,简称为NERDTree界面,右则为vim界面. 一.配置步骤 下载地址: http://ww ...
- 事件tou
#define EV_TIMER_RESOLUTION 1 /* 1 msec */ #define EV_READ_EVENT EPOLLIN #define EV_WRITE_EVENT EPOL ...
- hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告
这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...