解题报告:

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

 #include<cstdio>
#include<cstring>
int times[]; int main() {
int N,d;
while(scanf("%d",&N)!=EOF) {
memset(times,,sizeof(times));
for(int i = ;i<=N;++i) {
scanf("%d",&d);
times[d]++;
}
int max = ;
for(int i = ;i<=;++i)
if(times[i]>times[max])
max = i;
printf("%d\n",max);
}
return ;
}

HDU 1029 Ignatius and the Princess IV的更多相关文章

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

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

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

  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 DP

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

  9. HDU 1029 Ignatius and the Princess IV(数论)

    #include <bits/stdc++.h> using namespace std; int main(){ int n; while(~scanf("%d",& ...

随机推荐

  1. I belonged to you

    小葫芦,你就像山间清爽的风,犹如古城温暖的光,在我的旅途中陪伴着我. 我想牵着你的手,踏遍万水千山,赏遍美景风光,春观夜樱,夏望繁星,秋赏满月,冬会初雪. 直到两鬓斑白,一起坐在火炉旁,给孩子们讲故事 ...

  2. C#基础知识系列九(对IEnumerable和IEnumerator接口的糊涂认识)

    前言 IEnumerable.IEnumerator到现在为止对这两个接口还是不太理解,不理解但是自己总是想着试着要搞明白,毕竟自己用的少,所以在此先记录一下.以备自己日后可以来翻查,同时也希望园子里 ...

  3. 微信WeixinJSBridge API

    <!DOCTYPE html><html> <head> <title>微信WeixinJSBridge API</title> <m ...

  4. git 使用教程整理

    饥人谷最优技术博客,Git使用三部曲系列--朱维(直播10班)<创建版本库>http://t.cn/RfRbSY8<查看状态>http://t.cn/Rfn2TkP<版本 ...

  5. java多线程-CountDownLatch

    简介 一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待.用给定的计数 初始化 CountDownLatch.由于调用了 countDown() 方法,所以在当前计数 ...

  6. nginx 的中文配置详细解释

    文章转自:http://www.ha97.com/5194.html 更详细的模块参数请参考:http://wiki.nginx.org/Main #定义Nginx运行的用户和用户组 user www ...

  7. WordPress Option API(数据库储存 API)

    WordPress Option API 是提供给开发者的数据库存储机制,通过调用函数,可以快速.安全的把数据存储到数据库里(都在 wp_options 表). 每个设置的模式是 key – valu ...

  8. 【转】高斯消元模板 by kuangbin

    写的很好,注释很详细,很全面. 原blog地址:http://www.cnblogs.com/kuangbin/archive/2012/09/01/2667044.html #include< ...

  9. Java 编辑tips

    1.      windows 安装 jdk配置环境 1) 下载jdk,正常安装结束,保存安装路径. 2)我的电脑—〉右键属性—〉高级系统设置—〉环境变量—〉添加系统变量 新建两个变量 JAVAHOM ...

  10. BZOJ-1228 E&D 博弈SG+找啊找啊找规律

    讨厌博弈,找规律找半天还是错的.... 1228: [SDOI2009]E&D Time Limit: 10 Sec Memory Limit: 162 MB Submit: 666 Solv ...