您的位置:首页 > 其它

HDU_1029 Ignatius and the Princess IV

2011-08-06 08:24 375 查看
  这题的数据有点问题,给的N个数里边最大的数是多少不知道,直接猜了个数用hash做了,居然1A了。。。。

#include <stdio.h>
#include <string.h>
#define N 100007
int hash
;
int main()
{
int n, i, a;
while(scanf("%d", &n) != EOF)
{
memset(hash, 0, sizeof(hash));
int max = -1;
while(n--)
{
scanf("%d", &a);
if(a > max) max = a;
hash[a]++;
}
int num = -1, flag;
for(i = 1; i <= max; i++)
if(hash[i] > num)
{
num = hash[i];
flag = i;
}
printf("%d\n",flag);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: