题意:给 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. Linux 链接网络

    目录 查看网卡 存在多个网卡 网卡配置静态IP 报错总结 诚邀访问我的个人博客:我在马路边 更好的阅读体验点击查看原文:Linux链接网络 原创博客,转载请注明出处 @ Linux在安装系统结束后总要 ...

  2. Java处理乱码问题

    中文乱码分为GET乱码和POST乱码 GET乱码在Tomcat中配置编码 <Connector port="8080" protocol="HTTP/1.1&quo ...

  3. Maven实现直接部署Web项目到Tomcat7

    如题目,自动部署到Web服务器,直接上过程. 1.Tomcat7的用户及权限配置:在conf目录下,找到tomcat-users.xml,添加manager权限的用户. <role rolena ...

  4. Qt Creator 中的段落 注释的 快捷方法【转载】

    原文网址:http://jingyan.baidu.com/article/d5c4b52bc2bd1dda560dc5bb.html 作为一名合格的程序员,漂漂亮亮的注释是必须的!!怎么在Qt Cr ...

  5. svn更新报错:出现skipped:目标路径

    skipped 意为:跳过此目标文件: 一般出现在目标文件被删除后,重新更新情况下: 解决办法及结果: 1,回到此目标文件的上一层文件夹,team-clean up,结果不成功 2,回到此目标文件的上 ...

  6. vector向量容器元素排序与查找

    1.利用标准库函数sort()对vector进行排序 参考源码: #include <algorithm> #include <vector> vector<int> ...

  7. eclipse插件安装(个人版)

    1.Eclipse 安装反编译插件jadclipse http://jingyan.baidu.com/article/3f16e003c857082590c1036f.html 2.MyEclips ...

  8. 转:利用UDEV服务解决RAC ASM存储设备名

    利用UDEV服务解决RAC ASM存储设备名 好文转载,链接:http://www.askmaclean.com/archives/utilize-udev-resolve-11gr2-rac-asm ...

  9. 2 ignite关键特性

    数据注入和流计算: Ignite流式计算允许以可扩展和容错的方式处理连续不中断的数据流.在一个中等规模的集群中,数据注入Ignite的比例会很高,很容易达到每秒百万级的规模. Ignite可以与主要的 ...

  10. mybatis 学习四(下) SQL语句映射文件增删改查、参数、缓存

    2.2 select 一个select 元素非常简单.例如: <!-- 查询学生,根据id --> <select id="getStudent" paramet ...