http://acm.hdu.edu.cn/showproblem.php?pid=5038

模拟水题

求出现次数最多的grade。如果有多个grade出现的次数一样多,且还有其他的grade,则把这些出现次数最多的grade按升序输出;否则,输出“Bad Mushroom”。

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
int n;
int s[1000005];
int cnt[10005];
int main(){
int _,w,cas = 1;
RD(_);
while(_--){
RD(n);
clr0(cnt);
for(int i = 0;i < n;++i){
scanf("%d",&w);
s[i] = 10000 - (100 - w)*(100 - w);
cnt[s[i]]++;
}
int mn = 20000000,mx = -1;
vector <int> ans;
for(int i = 0;i <= 10000;++i){
if(cnt[i]){
mn = min(cnt[i],mn);
mx = max(cnt[i],mx);
}
}
for(int i = 0;i <= 10000;++i){
if(cnt[i] == mx){
ans.push_back(i);
}
}
printf("Case #%d:\n",cas++);
if(mn == mx && ans.size() != 1){
puts("Bad Mushroom");
}else{
for(int i = 0;i < ans.size();++i){
printf("%d%c",ans[i]," \n"[i == ans.size() - 1]);
}
} }
return 0;
}

最新文章

  1. Designing for iOS: Graphics &amp; Performance
  2. JavaScript 写几个简单的知识点
  3. leetcode 20
  4. js细节
  5. C语言-数据的快速引用
  6. paip.c++ qt 项目工程互相引用的方法
  7. canvas的使用
  8. VC维含义的个人理解
  9. CSS学习笔记day1
  10. java知识点总结--java开发环境搭建
  11. mybatis入门 配置文件解释 及测试
  12. MYSQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column &#39;
  13. 让我对 docker swarm mode 的基本原理豁然开朗的几篇英文博文
  14. Java语言的简介
  15. WijmoJS 全面支持 Angular 7
  16. git常用命令(todo...)
  17. 【转帖】 redis 命令 From https://www.cnblogs.com/zhouweidong/p/7550717.html
  18. 013-安装VNC服务
  19. [Delphi]带进度条的ListView
  20. .NET平台下开源三维 GIS (地形与游戏)平台资料

热门文章

  1. C语言高级-结构,共用体,文件,链表
  2. Mysql通过SQL脚本复制表
  3. fieldOfView
  4. 兼容谷歌、火狐、IE7.0以上浏览器div+css实现的带有蒙版的半透明弹窗效果[xyytit]
  5. struts框架问题四之获取到值栈的对象
  6. centos7之iptables与firewalld
  7. send发送一次buffer
  8. Jmeter中正则表达式不区分大小写进行匹配
  9. asp.net web 通过IHttpAsyncHandler接口进行消息推送
  10. boost 学习(1)