题意:输入n个数 n为奇数 问某个数出现的次数大于等于(N+1)/2的是 哪个 输出来
Sample Input
5
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

Sample Output
3
5
1

 #include <queue>
#include <map>
using namespace std; map<int ,int> m ; int main()
{
int n ;
while(scanf("%d" , &n) !=EOF)
{
m.clear() ;
int i ,x ;
for (i = ; i <= n ;i++)
{
scanf("%d" , &x) ;
m[x]++;
}
map<int ,int>::iterator p ;
for (p = m.begin() ; p != m.end() ; p++)
{
if (p->second >= (n+)/)
{
printf("%d\n" , p->first) ;
break ;
}
} } return ;
}

HDU 1029 某个数出现的次数大于等于(N+1)/2的是哪个 map水题的更多相关文章

  1. Java编程题(1):n个数里出现次数大于等于n/2的数

    题目描述:输入n个整数,输出出现次数大于等于数组长度一半的数. 输入描述:每个测试输入包含 n个空格分割的n个整数,n不超过100,其中有一个整数出现次数大于等于n/2. 输出描述:输出出现次数大于等 ...

  2. hdu 1004 颜色与数字(map水题)

    Sample Input5 //Tgreenredblueredred 统计颜色的次数 输出最多的颜色3pinkorangepink0 Sample Outputred pink # include ...

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

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

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

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

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

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

  7. hdu 1029(hash)

    传送门:Ignatius and the Princess IV 题意:给n个数,找出出现次数大于等于(n+1)/2的那个数. 分析:大水题,排个序输出中间那个即可,这里随便写个HASHMAP找出次数 ...

  8. hdu 1029 Ignatius ans the Princess IV

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

  9. HDU 1029 Ignatius and the Princess IV

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

随机推荐

  1. .Net进阶系列(4)-Lambda和linq入门(被替换)

    一. Lambda和linq入门 lambda表达式又叫点标记,linq表达式又叫查询表达式,下面有三个简单的案例说明一下二者的基本用法,详细用法会在后续章节中更新. 二. 事例 1. 准备学生信息. ...

  2. 简述var、let、const三者的区别

    前二者为定义变量,const一般用来定义常量. 1.var声明变量可以重复声明,而let不可以重复声明 var name = 'xiaohuang'; var name = 'xiaolan'; co ...

  3. MyBatis参数传递

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  4. 三、u-boot 的配置-mkconfig 脚本

    3.1 mkconfig 脚本 100ask24x0_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL ...

  5. elasticsearch 单机多实例

    elasticsearch 配置单机器多实例 host: - - path data: /opt/elasticsearch/data/node1 /opt/elasticsearch/data/no ...

  6. dubbo服务使用spring-data-mongodb进行时间查询的bug记录

    一.项目情况:spring-boot+mongodb+dubbo. 二.问题:调用dubbo服务并使用spring-data-mongodb的gte,lte时间段比较查询, @Reference(re ...

  7. luogu P3674 小清新人渣的本愿

    传送门 毒瘤lxl 本质是莫队,关键是怎么处理询问 这里需要开两个bitset(记为\(b1,b2\)),分别存\(x\)和\(n-x\)是否出现 对于询问1,即\(x-y=z\),由于\(y=x-z ...

  8. <转载>iTerm2使用技巧

    原文链接:http://www.cnblogs.com/756623607-zhang/p/7071281.html   1.设置窗口 定位到 [Preferences - Profiles - Wi ...

  9. android的五个进程优先级,内存不足时被清理的顺序

    Android操作系统尝试尽可能长时间的保持应用的进程,但当可用内存很低时最终要移走一部分进程.怎样确定那些程序可以运行,那些要被销毁,Android让每一个进程在一个重要级的基础上运行,重要级低的进 ...

  10. POI导出Excel(xls、xlsx均可以,也支持图片)——(三)

    Jar包