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的

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; const int MAXN = 1e6+200;
int g[MAXN];
int a[MAXN],n,vis[MAXN];
int cnt[MAXN];
int out[MAXN];
//map<int,int>cnt; int main()
{
//IN("hdu5038.txt");
int ncase,n;
scanf("%d",&ncase);
for(int ic=1;ic<=ncase;ic++)
{
CL(cnt,0);
CL(vis,0);
scanf("%d",&n);
int mmax=0;//,mm=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
g[i]=10000 - (100-a[i])*(100-a[i]);
cnt[g[i]]++;
//vis[a[i]]=1;
mmax=max(mmax,cnt[g[i]]);
// mm=max(mm,g[i]);
}
int flag=0;
int cc=0;
for(int i=0;i<n;i++)
{
if(mmax == cnt[g[i]] && !vis[g[i]])
{
out[cc++]=g[i];
vis[g[i]]=1;
}
if(mmax != cnt[g[i]])
{
flag=1;
}
}
printf("Case #%d:\n",ic);
if(flag==0 && cc>1)puts("Bad Mushroom");
else
{
sort(out,out+cc);
printf("%d",out[0]);
int last=out[0];
for(int i=1;i<cc;i++)
{
if(out[i]!=last)
{
last=out[i];
printf(" %d",out[i]);
}
}
putchar('\n');
}
}
return 0;
}

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. Python 2.7.9 Demo - 005.字符串判空

    #coding=utf-8 #!/usr/bin/python str1 = None; str2 = ''; str3 = ' '; if str1 == None : print("st ...

  2. destoon的如何显示tag生成的sql语句

    destoon 如何显示tag生成的sql语句 在tag.func.php中第117行加入 echo $query;  就只可以了

  3. c++ 使用vs2010调用 win32api

    以前读书时都是用vc6.0.后来学c#用vs.装系统只装了vs2010.今天用vs2010写c++程序.发现有点陌生.就总结下,免得以后忘记. 首先用vs2010选择c++语言.新建一个win32控制 ...

  4. js 三元表达式

    JavaScript三元运算符的多种使用技巧 发现代码慢慢写多了的时候会不自觉的将if else 用 三元来替代,仅仅是未了让代码更简洁精辟,当然也有人说用三元可以让你有高潮的感觉.最近在写js 的时 ...

  5. 小tip: 如何让contenteditable元素只能输入纯文本

    div模拟textarea文本域轻松实现高度自适应 这篇文章发布于 2010年12月23日,星期四,22:07,归类于 css相关. 阅读 112630 次, 今日 40 次 by zhangxinx ...

  6. JS模块的写法

    该文章转自阮一峰个人网站,仅做学习之用: 一.原始写法 模块就是实现特定功能的一组方法. 只要把不同的函数(以及记录状态的变量)简单地放在一起,就算是一个模块. function m1(){ //.. ...

  7. 解决 Plugin with id 'com.github.dcendents.android-maven' not found.

    在Android studio中引用第三方库的时候,报这个错. Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not ...

  8. Ubuntu下SSH安装及提高SSH登陆认证速度的办法

    Ubuntu 下安装 OpenSSH Server 是无比轻松的一件事情,需要的命令只有一条: sudo apt-get install openssh-server (查看返回的结果,如果没有出错, ...

  9. [Django学习]视图

    视图 视图接受Web请求并且返回Web响应 视图就是一个python函数,被定义在views.py中 响应可以是一张网页的HTML内容,一个重定向,一个404错误等等 响应处理过程如下图: 1. UR ...

  10. 常用的百度API地图操作

    常用的百度API地图操作,包括模糊搜索,放大缩小,并支持移动端 效果图如下 完整代码: http://download.csdn.net/detail/jine515073/8778167