HDU 1029 Ignatius and the Princess IV
解题报告:
题目大意:就是要求输入的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的更多相关文章
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- 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 ...
- 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 ...
- hdu 1029 Ignatius ans 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 ...
- HDU 1029 Ignatius and the Princess IV (动态规划、思维)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- HDOJ/HDU 1029 Ignatius and the Princess IV(简单DP,排序)
此题无法用JavaAC,不相信的可以去HD1029题试下! Problem Description "OK, you are not too bad, em- But you can nev ...
- HDU 1029 Ignatius and the Princess IV DP
kuangbin 专题 这题,有很多种解法. 第一种: 直接比较每个数出现次数. #include<iostream> #include<string> #include< ...
- HDU 1029 Ignatius and the Princess IV(数论)
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(~scanf("%d",& ...
随机推荐
- Github上Python开发者应该关心的Repo
carbaugh/lice lice : Generate license files for your projects 一个用来为你的项目生成许可证的工具.这下可方便了,不用手工的去修改了! co ...
- Qt程序启动画面播放(gif与swf两种动画格式)
学习Qt有一段时间了,发现一个小问题,网上关于Qt的资料或者总结性的学习及应用文章有点少. 比如,Qt完整的API,程序运行之前的启动画面如何按理想效果播放等,每次想在项目中添加一些应用的时候,总是找 ...
- (旧)子数涵数·Flash——Flash Player的操作命令
一.什么是Flash Player? Flash Player就是官方指定的一种FLash播发器. 用百度的话来讲,Adobe Flash Player 是一款高级客户端运行时使用的播放器.它短小精悍 ...
- ubuntu中管理用户和用户组
1. 添加一个用户组并指定id为1002 sudo groupadd -g 1002 www 2. 添加一个用户到www组并指定id为1003 sudo useradd wyx -g 1002 -u ...
- node的实践(项目一)
学习一门语言,我们先要学习他的基本的语法,基本的数据类型,基本的数组操作,字符串的操作,然后就是语言的特性,实现共享和降低耦合的方式,然后开始比较高级的学习(所有语言都是一样的),比如说通信方法,tc ...
- Javascript基础系列之(五)条件语句(比较操作符)
和其他语言一样,JavaScript也有条件语句对流程上进行判断.包括各种操作符合逻辑语句 比较操作符 常用的比较操作符有 等于 == , 不等于!= , 大于 >, 小于 < ...
- java多线程-Semaphore信号量使用
介绍 信号量(Semaphore),有时被称为信号灯,是在多线程环境下使用的一种设施, 它负责协调各个线程, 以保证它们能够正确.合理的使用公共资源. 概念 Semaphore分为单值和多值两种,前者 ...
- ASP.NET加JS方式
一.如果是asp.net中的控件有OnClientClick事件,可以在控件中直接加 OnClientClick--客户端点击事件 二.如果asp.net中的控件没有OnClientClick事件,可 ...
- Java设计模式-访问者模式(Visitor)
访问者模式把数据结构和作用于结构上的操作解耦合,使得操作集合可相对自由地演化.访问者模式适用于数据结构相对稳定算法又易变化的系统.因为访问者模式使得算法操作增加变得容易.若系统数据结构对象易于变化,经 ...
- MVC的URL路由规则
MVC的URL路由规则 Routing的作用:它首先是获取到View传过来的请求,并解析Url请求中Controller和Action以及数据,其次他将识别出来的数据传递给Controller的Act ...