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; }
相关文章推荐
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV(水题)
- HDU-OJ-1029 Ignatius and the Princess IV-出现至少(N+1)/2次的数
- hdu 1029 Ignatius and the Princess IV(快排)
- HDU-1029 Ignatius and the Princess IV
- HDU-1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU - 1029 B - Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV 动态规划
- Hdu 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV(水题)
- HDU1029 Ignatius and the Princess IV【排序】
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- 【HDU】1029 - Ignatius and the Princess IV(STL || 思维)
- HDU 1029 Ignatius and the Princess IV