hdu 5038 水题 可是题意坑
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 水题 可是题意坑的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- HDU - 5078 水题
题意:最大困难=距离 / 相邻时间 #include<cstring> #include<cstdio> #include<cmath> #define ll do ...
随机推荐
- iOS-ARC_Xcode检测循环引用
iOS-ARC_Xcode检测循环引用 一,在桌面上新建立一个工程,在ViewController.m中输入如下代码: - (void)viewDidLoad { [super viewDidLoad ...
- Spring Boot干货系列:(二)配置文件解析
Spring Boot干货系列:(二)配置文件解析 2017-02-28 嘟嘟MD 嘟爷java超神学堂 前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用“习惯优于 ...
- Maven-7:Maven配置编译的字符集方法
http://blog.csdn.net/jsjszg/article/details/9237189 ************************************************ ...
- 标准库string的用法探讨
之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至 ...
- 在chrome中的source找不到自己写的js时处理方法
今天准备调试下js,突然发现在谷歌的中source中找不到我要调试的js,后来查资料和听同事说谷歌会把js压缩,于是找到以下方法来调试js 1. debugger神器 横扫各个浏览器.脚本运行到deb ...
- 【WPF/WAF】主界面(ShellWindow)引入别的界面布局
问题:主界面如果只用一个布局文件ShellWindow.xaml,会写得很大很臃肿.需要分为多个布局文件,然后由主界面引入.参考http://waf.codeplex.com/官方的BookLibra ...
- git学习(四):理解git暂存区(stage)
与一般的版本管理不同的是,git在提交之前要将更改通过git add 添加到暂存区才能提交(git commit).即使是已经交给了git来管理的文件也是如此.这里继续学习git的暂存区. 通过git ...
- [uart]理解线路规程的作用
转自:http://biancheng.dnbcw.info/linux/336240.html Linux OS的设备驱动有相当经典的抽象思想以及分层思想.与通信世界里面的思想相一致. 一.在Lin ...
- SpringMVC 多视图解析器配置以及问题
在SpringMVC模式当中可以通过如下配置来支持多视图解析 <!-- jsp jstl --> <bean id="JSPViewResolver" class ...
- d3js技术文档
D3js技术文档 概述 D3 allows you to bind arbitrary data to a Document Object Model (DOM), and then apply ...