题意:给 n 个数,输出众数,但是如果所有的频率都相同但数不同输出 Bad Mushroom。

析:直接记录个数直接暴力就,就是要注意只有一种频率的时候。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e16;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 10000 + 10;
const int mod = 100000000;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int a[maxn]; int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
scanf("%d", &n);
memset(a, 0, sizeof a);
for(int i = 0; i < n; ++i){
int x;
scanf("%d", &x);
x = 10000 - (100-x) * (100-x);
++a[x];
}
int mmax = 0;
vector<int> v;
int cnt = 0;
for(int i = 0; i <= 10000; ++i){
if(a[i] == 0) continue;
++cnt;
if(mmax < a[i]){
v.clear();
mmax = a[i];
v.push_back(i);
}
else if(mmax == a[i]) v.push_back(i);
}
printf("Case #%d:\n", kase);
if(cnt == 1) printf("%d", v[0]);
else if(cnt == v.size()) printf("Bad Mushroom");
else for(int i = 0; i < v.size(); ++i){
if(i) putchar(' ');
printf("%d", v[i]);
}
printf("\n");
}
return 0;
}

  

HDU 5038 Grade (水题,坑题)的更多相关文章

  1. HDU 5038 Grade(分级)

    Description 题目描述 Ted is a employee of Always Cook Mushroom (ACM). His boss Matt gives him a pack of ...

  2. HDU 2985 Another lottery(坑题)

    点我看题目 题意 : 有n个人,每个人可以玩m轮,每一轮中每个参与者都有cj张票,第 i 轮的奖金是2的i次方,问你每个人所能赢得最多的奖金的概率是多少. 思路 : 这个题比较坑啊,其实不用去算前几轮 ...

  3. HDU 6034 Balala Power! (贪心+坑题)

    题意:给定一个 n 个字符串,然后问你怎么给 a-z赋值0-25,使得给定的字符串看成26进制得到的和最大,并且不能出现前导0. 析:一个很恶心的题目,细节有点多,首先是思路,给定个字符一个权值,然后 ...

  4. HDU 5038 Grade

    解题思路:这题最关键的是要读懂题意,If not all the value are the same but the frequencies of them are the same, there ...

  5. HDU 5038 Grade北京赛区网赛1005

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5038 解题报告:就是输入n个数w,定义s = 10000 - (100 - w)^2,问s出现频率最高 ...

  6. hdu 5455 Fang Fang 坑题

    Fang Fang Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5455 ...

  7. hdu 5038 求出现次数最多的grade

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 模拟水题 求出现次数最多的grade.如果有多个grade出现的次数一样多,且还有其他的grade,则把这 ...

  8. 【BZOJ-1952】城市规划 [坑题] 仙人掌DP + 最大点权独立集(改)

    1952: [Sdoi2010]城市规划 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 73  Solved: 23[Submit][Status][ ...

  9. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

随机推荐

  1. docker容器与宿主机之间内容拷贝

    来自:http://blog.csdn.net/yangzhenping/article/details/43667785 常用的方式有3种: 从容器内拷贝文件到主机上 docker cp <c ...

  2. redis之 Redis常用数据类型

    Redis最为常用的数据类型主要有以下7种: 一. String (字符) 常用命令:  set,get,decr,incr,mget 等. 应用场景:String是最常用的一种数据类型,普通的key ...

  3. [转]深入详解javascript之delete操作符

    最近重新温习JS,对delete操作符一直处于一知半解的状态,偶然发现一篇文章,对此作了非常细致深入的解释,看完有茅塞顿开的感觉,不敢独享,大致翻译如下. 原文地址:http://perfection ...

  4. Ant能干什么,编译?打包!

    Ant轻便,灵巧,不像Maven一般沉重. 但是,这是我之前的看法.之前一直使用Eclipse自带的编译工具进行编译,然后采用ant进行打包:但是Eclipse编译工具编译之后的jar包参数名称之类的 ...

  5. BZOJ2054:疯狂的馒头

    浅谈并查集:https://www.cnblogs.com/AKMer/p/10360090.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php? ...

  6. mysql下this is incompatible with sql_mode=only_full_group_by解决方案

    本地测试没有问题,部署到客户服务器之后报如下错误: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 o ...

  7. 第9章 DOM对象,控制HTML元素

    学习地址:http://www.imooc.com/learn/10

  8. laravel 配置文件的使用

    在开发的时候有许多数据是固定的 或者是多处使用的, 那么我们可以把它保存到配置文件中, 这样将来我们可以直接从配置文件中读取这个数据,如果有特殊的数据需要改变的时候,我们也可以在单独特定的环境中,不使 ...

  9. MyBatis 批量插入数据对插入记录数的限制

    <基于 MyBatis 框架的批量数据插入的性能问题的探讨>(作者:魏静敏 刘欢杰 来源:<计算机光盘软件与应用> 2013 年第 19 期)中提到批量插入的记录数不能超过10 ...

  10. [cinder] volume type 使用简记

    cinder type-create sharecinder type-key share set volume_backend_name=GLUSTERFScinder type-create lo ...