题意:求出现次数>=(N+1)/2的数

思路:排序后,输出第(N+1)/2个数

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std; int a[]; int main(){
int n,i;
while(~scanf("%d",&n)){
for(i=;i<n;++i)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d\n",a[(n+)/-]);
}
return ;
}

hdu 1029 Ignatius and the Princess IV(排序)的更多相关文章

  1. 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 ...

  2. HDU 1029 Ignatius and the Princess IV --- 水题

    HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...

  3. 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 ...

  4. hdu 1029 Ignatius ans the Princess IV

    Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K ( ...

  5. [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 ...

  6. HDU 1029 Ignatius and the Princess IV (动态规划、思维)

    Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K ( ...

  7. HDOJ/HDU 1029 Ignatius and the Princess IV(简单DP,排序)

    此题无法用JavaAC,不相信的可以去HD1029题试下! Problem Description "OK, you are not too bad, em- But you can nev ...

  8. HDU 1029 Ignatius and the Princess IV

    解题报告: 题目大意:就是要求输入的N个数里面出现的次数最多的数是哪一个,水题.暴力可过,定义一个一位数组,先用memset函数初始化,然后每次输入一个数就将下标对应的上标对应的那个数加一,最后将整个 ...

  9. HDU 1029 Ignatius and the Princess IV DP

    kuangbin 专题 这题,有很多种解法. 第一种: 直接比较每个数出现次数. #include<iostream> #include<string> #include< ...

随机推荐

  1. 获取非行间样式getComputedStyle

    有如下代码: 1 2 3 div {     width: 200px; } 1 2 3 <div id="aa" style="height: 100px;&qu ...

  2. ant的安装和配置

    1.从官网下载bin源码 http://ant.apache.org/bindownload.cgi#Verify%20Releases 校验源码的完整性 2.直接把解压,然后把文件放入/usr/lo ...

  3. hdu5379||2015多校联合第7场1011 树形统计

    pid=5379">http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is ...

  4. iOS7系统中的坑——UITableViewCellScrollView

    今天开完一系列例会后,终于迎来放假的时候了,本来中午就要下班走的,想着火车票现在还很早,也就不急着走,闲着无聊,想着之前要写的内容,索性写一篇聊以打发时光,也希望对其他人有所帮助吧. 现在iOS的最新 ...

  5. linux中断子系统:中断号的映射与维护初始化mmap过程

    本文均属自己阅读源代码的点滴总结.转账请注明出处谢谢. 欢迎和大家交流.qq:1037701636 email:gzzaigcn2009@163.com 写在前沿: 好久好久没有静下心来整理一些东西了 ...

  6. cocosStudio中使用PageView,ListView和ScrollView

    晚上吃东西好像吃坏肚子了,.但是技术还要继续研究.最近工作中要使用CocosStudio做界面,好吧,不管对他有什么偏见,学习一下吧.这里主要记录一下三个控件的使用和说明.就是ScrollView,L ...

  7. python(26)- 面向对象补充Ⅱ

    一 isinstance(obj,cls)和issubclass(sub,super) isinstance(obj,cls)判断obj是否是类 cls 的对象 class Foo(object): ...

  8. 两种IO模式:Proactor与Reactor模式

    在高性能的I/O设计中,有两个比较著名的模式Reactor和Proactor模式,其中Reactor模式用于同步I/O,而Proactor运用于异步I/O操作. 在比较这两个模式之前,我们首先的搞明白 ...

  9. Fighting regressions with git bisect---within git bisect algorithm

    https://www.kernel.org/pub/software/scm/git/docs/git-bisect-lk2009.html Fighting regressions with gi ...

  10. 编程算法 - 多重部分和问题 代码(C)

    多重部分和问题 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 有n种不同大小的数字a, 每种各m个. 推断能否够从这些数字之中选出若干使它们的 ...