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