题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=5123

水题一个,直接hash;

代码

#include<stdio.h>
#include<string.h>

int main(void)
{
int i,j,k,n,t;
int a[110];
int hash[110];
scanf("%d",&t);
while(t--)
{
memset(hash,0,sizeof(hash));
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",a+i);
hash[a[i]]++;
}
int Max=0,tragt;
for(i=1;i<=n;i++)
{
if(hash[i]>Max)
{
Max=hash[i];
tragt=i;
}
}
printf("%d\n",tragt);
}
return 0;
}

官方解析

1001 who is the best?
我们对于每个ai都进行计数,即b[ai]++,如此之后,我们可以一个循环语句i=1−>n来寻找最大的bi,注意此时应是bi>MAX,而不是bi≤MAX,这样才能保证出现的是编号最小的。另外需要注意的是每次做完后数组应当清0,否则会影响下次的答案,由于各种非确定性因素我在小数据就已经把没清0的程序卡死了。

HDU-5123-who is the best?的更多相关文章

  1. HDU 4978 A simple probability problem

    A simple probability problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  2. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  4. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  5. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  6. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  8. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  9. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  10. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. 总结自己的Git常用命令

    总结自己的Git常用命令 使用git也有一段时间了,把自己常用的命令用自己的描述记录起来,方便自己备忘也方便其他人参考. 目录: 最基本的命令: git clone 拷贝并跟踪远程的master分支. ...

  2. Web安全检测工具的使用.

    Nikto2 Nikto2是一款使用perl语言写的多平台扫描软件,是一款命令行模式的工具,它可以扫描指定主机的WEB类型 主机名.特定目录.Cookie.特定CGI漏洞.XSS漏洞.sql注入漏洞. ...

  3. FZU Problem 2213 Common Tangents

    其实是不太好意思往博客上放的,因为是一道巨水的题,但是我却错了一次,没有判断重合,放上还是为了警示自己,尽量不要在水题上罚时 #include<iostream> #include< ...

  4. 有关sqlitedrop数据库重建比delete方式来清空数据库更加有效率

    今天浏览stackoverflow 发现一个有趣的问题: which was more preferable as performance wise and without error cause t ...

  5. flex4 list 自动适应高度

    <s:List width="100%"> <s:layout> <s:VerticalLayout useVirtualLayout="f ...

  6. select下拉框

    <optgroup label="Alaskan/Hawaiian Time Zone"> <option value="AK">Ala ...

  7. 红黑树(C#)

    红黑树C#算法. 在线javascript演示地址:http://sandbox.runjs.cn/show/2nngvn8w using System; using System.Collectio ...

  8. iOS开发——打包静态库与Framework

    最近老是需要做接口给别的客户,就顺便把打包的过程也写一下吧! 一.静态库 静态图里面只能是纯文件,里面不能再有第三方打包的静态库,也就是说,静态库不能打包静态库.这个用的比较多,一般自己公司写出来的东 ...

  9. tableView滑动到底部

    - (void)scrollToBottom { NSInteger sectionCount = [self.dataSource numberOfSectionsInTableView:self] ...

  10. STM32单片机在Keil5下仿真的问题解决及GPIO口初始化、使用

    STM32单片机在Keil5下仿真的问题解决及GPIO口初始化.使用 最近看了视频,里面有仿真,可以清楚看到GPIO口的数据变化,也想尝试下,DUG时却出现*** error 65: access v ...