K - Ignatius and the Princess IV
Description
"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
Output
Sample Input
Sample Output
#include <iostream>
#include <string.h>
using namespace std;
int s[];
int main()
{
int n;
while(cin>>n){
int j,max,a,t;
memset(s,,sizeof(s));
for(int i=;i<n;i++){
cin>>a;
s[a]++;
if(s[a]==(n+)/){
t=a;
}
}
cout<<t<<endl;
}
//system("pause");
return ;
}
K - 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 ( ...
- Ignatius and the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- (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 ...
- kuangbin专题十二 HDU1029 Ignatius and 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 (动态规划、思维)
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 ...
随机推荐
- 慕课linux学习笔记(四)常用命令(1)
Root 表示当前登录用户 Localhost 主机名 ~ 当前所在位置(~表示/root) # 超级用户 $ 普通用户 命令 1.pwd 显示当前所在位置 2.ls 查询目录中的内容 -a 显示所有 ...
- PHP连接Microsoft SQL Server 2005/2008
PHP自带的MSSQL扩展php_mssql.dll原来是给SQL Server 2000用的,难怪连接不上2008?! -_-!!要使用SQL Server 2005以上版本,就要用到微软为PHP提 ...
- eclipse修改字体
修改xml字体: window→Preferences→General→Colors and Fonts→Basic→Text Font
- 爬虫框架YayCrawler
爬虫框架YayCrawler 各位好!从今天起,我将用几个篇幅的文字向大家介绍一下我的一个开源作品——YayCrawler,其在GitHub上的网址是:https://github.com/liush ...
- Log4net从下载到使用例子
一.首先下载log4net.dll http://pan.baidu.com/s/1gdigrwJ 二.添加log4net引用 三.代码: using System; using System.C ...
- 10个经典的Android开源项目(附源码包)
最近在抽空学习Android系统开发,对Android学习也比较感兴趣,刚开始学就试着在网上找几个项目源码研究看下,以下就将找到的Android项目源码列出,希望对正在或准备学习Android系统开发 ...
- LeetCode_Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. /* ...
- PHPDocumentor安装与使用
phpDocuemtor官网:http://www.phpdoc.org/ 通过pear安装,进入dos的php目录,输入pear install -a PhpDocumentor.如果想使用web接 ...
- Tomcat启动load action异常
近期将之前的项目移到另一个文件夹中(包的路径也更改了),启动Tomcat之后包错:无法加载action,看错误提示知道是路径错误,网上也有各种各样的解决方案,这里我的错误是因为项目移到了别的文件中,所 ...
- 利用智能手机(Android)追踪一块磁铁(三)
更新磁铁追踪算法的源代码,Android Studio项目工程 github地址:https://github.com/amazingyyc/MagnetLocate 说明:将磁铁的位置信息封装成消息 ...