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

就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了

可是这句话真恶心  If not all the value are the same but the frequencies of them are the same, there is no mode.

事实上应该是这个意思:

当频率最高的有多个的时候。

假设 全部的grade出现的频率都是相等的,那么是没有mode的

否则依照升序

当然假设频率最高的有一个。还是有mode的

  1. //#pragma comment(linker, "/STACK:102400000,102400000")
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <string>
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <cmath>
  9. #include <map>
  10. #include <set>
  11. #include <queue>
  12. using namespace std;
  13.  
  14. #define ls(rt) rt*2
  15. #define rs(rt) rt*2+1
  16. #define ll long long
  17. #define ull unsigned long long
  18. #define rep(i,s,e) for(int i=s;i<e;i++)
  19. #define repe(i,s,e) for(int i=s;i<=e;i++)
  20. #define CL(a,b) memset(a,b,sizeof(a))
  21. #define IN(s) freopen(s,"r",stdin)
  22. #define OUT(s) freopen(s,"w",stdout)
  23. const ll ll_INF = ((ull)(-1))>>1;
  24. const double EPS = 1e-8;
  25. const double pi = acos(-1.0);
  26. const int INF = 100000000;
  27.  
  28. const int MAXN = 1e6+200;
  29. int g[MAXN];
  30. int a[MAXN],n,vis[MAXN];
  31. int cnt[MAXN];
  32. int out[MAXN];
  33. //map<int,int>cnt;
  34.  
  35. int main()
  36. {
  37. //IN("hdu5038.txt");
  38. int ncase,n;
  39. scanf("%d",&ncase);
  40. for(int ic=1;ic<=ncase;ic++)
  41. {
  42. CL(cnt,0);
  43. CL(vis,0);
  44. scanf("%d",&n);
  45. int mmax=0;//,mm=0;
  46. for(int i=0;i<n;i++)
  47. {
  48. scanf("%d",&a[i]);
  49. g[i]=10000 - (100-a[i])*(100-a[i]);
  50. cnt[g[i]]++;
  51. //vis[a[i]]=1;
  52. mmax=max(mmax,cnt[g[i]]);
  53. // mm=max(mm,g[i]);
  54. }
  55. int flag=0;
  56. int cc=0;
  57. for(int i=0;i<n;i++)
  58. {
  59. if(mmax == cnt[g[i]] && !vis[g[i]])
  60. {
  61. out[cc++]=g[i];
  62. vis[g[i]]=1;
  63. }
  64. if(mmax != cnt[g[i]])
  65. {
  66. flag=1;
  67. }
  68. }
  69. printf("Case #%d:\n",ic);
  70. if(flag==0 && cc>1)puts("Bad Mushroom");
  71. else
  72. {
  73. sort(out,out+cc);
  74. printf("%d",out[0]);
  75. int last=out[0];
  76. for(int i=1;i<cc;i++)
  77. {
  78. if(out[i]!=last)
  79. {
  80. last=out[i];
  81. printf(" %d",out[i]);
  82. }
  83. }
  84. putchar('\n');
  85. }
  86. }
  87. return 0;
  88. }

hdu 5038 水题 可是题意坑的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  3. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  4. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  5. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. HDU - 5078 水题

    题意:最大困难=距离 / 相邻时间 #include<cstring> #include<cstdio> #include<cmath> #define ll do ...

随机推荐

  1. Oracle PLSQL Demo - 24.分隔字符串function

    -- refer: -- http://www.cnblogs.com/gnielee/archive/2009/09/09/1563154.html -- http://www.cnblogs.co ...

  2. SQLYog Enterprise注册码分享

    SQLYog Enterprise注册码 Name:3ddownSerial:7c799fe606582b12 用户名:luowuzhe注册码:c84a12fa6ea3cb54   SQLyog 8. ...

  3. web.xml 基本配置

    session timeout 配置 <session-config> <session-timeout>5</session-timeout> </sess ...

  4. iOS 键盘处理(改变键盘为完成键),UITextField键盘显示隐藏,弹出,回弹

    很多时候用到UITextField时,处理键盘是一个很棘手的问题. 问题一:如何隐藏键盘? 方案1.改变键盘右下角的换行(enter)键为完成键,后实现代理方法键盘自动回弹 keyBoardContr ...

  5. iOS网络NSURLSession使用详解

    一.整体介绍 NSURLSession在2013年随着iOS7的发布一起面世,苹果对它的定位是作为NSURLConnection的替代者,然后逐步将NSURLConnection退出历史舞台.现在使用 ...

  6. C++基础学习-20120518

    1---------printf中的%f会自动转化成double 2---------static_cast的应用实际上static_cast真正用处并不在指针和引用上,而在基础类型和对象的转换上 s ...

  7. mongodb常见管理命令

    ----------1.复制数据库 wind:PRIMARY> show dbs; jinri 0.078GB local 1.078GB test 0.078GB wind 0.078GB w ...

  8. C语言 · 数字三角形

    算法训练 数字三角形   时间限制:1.0s   内存限制:256.0MB      问题描述 (图3.1-1)示出了一个数字三角形. 请编一个程序计算从顶至底的某处的一条路 径,使该路径所经过的数字 ...

  9. Kafka_Zookeeper_环境搭建使用

    Kafka 安装和测试 1. 简介 kafka (官网地址:http://kafka.apache.org)是一款分布式消息发布和订阅的系统,具有高性能和高吞吐率. i. 消息的发布(publish) ...

  10. CSS(一):CSS简介和基本语法

    一.CSS简介 1.什么是CSS CSS:Cascading Style Sheet:即层叠样式表.样式定义了如何显示HTML或XHTML元素.包括对字体.颜色.边距.高度.宽度.背景图片.网页定位等 ...