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 ...
随机推荐
- Java IP地址字符串与BigInteger的转换, 支持IPv6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- oracle判断查询结果是否为空
create table test1023(id int); --创建测试表 test1023 declare cnt int; begin select count(*) into cnt from ...
- PLSQL Developer新手使用教程(图文教程)
PLSQL Developer是Oracle数据库开发工具,很牛也很好用,PLSQL Developer功能很强大,可以做为集成调试器,有SQL窗口,命令窗口,对象浏览器和性能优化等功能,下面简单的介 ...
- linux 基本配置tab键和显示行号 和中文输入法
一.仅设置当前用户的Tab键宽度 输入命令:vim ~/.vimrc 然后:set tabstop=4 //我这里将Tab键的宽度设置为4 保存:ctrl+z+z(或:wq!) OK! 二.设置所 ...
- java 关于同步异步的理解
经常看到介绍 ArrayList 和HashMap是异步,Vector和HashTable是同步,这里同步是线程安全的,异步不是线程安全的,举例说明: 当创建一个Vector对象时候, Vector ...
- 【C#】事件(Event)和代理/委托(Delegate)
代理(Delegate)的例子 delegate void MyDelegate(string str,int index); // 声明代理 class Test { public static v ...
- BM和KMP字符串匹配算法学习
BM和KMP字符串匹配算法学习 分类: 研究与学习 字符串匹配BM(Boyer-Moore)算法学习心得 http://www.cnblogs.com/a180285/archive/2011/12/ ...
- Android——Handler 多线程
java 打开界面 实现图片轮播 //Handler final ImageView iv_2 = (ImageView)findViewById(R.id.iv_2); final int[] im ...
- Redis Key 过期策略
redis 官方提供的 conf https://raw.github.com/antirez/redis/2.2/redis.conf 中6中过期策略的具体方式.redis 中的默认的过期策略是vo ...
- iOS开发小技巧--cell往左拖拽出现很多按钮的实现,仅仅适用于iOS8以后
// 往左拖拽cell出现多个按钮的实现,仅仅适用于iOS_8.0以后 - (NSArray<UITableViewRowAction *> *)tableView:(UITableVie ...