HDU5032--Grade
来源:互联网 发布:linux清空文件内容 编辑:程序博客网 时间:2024/06/01 10:10
Ted is a employee of Always Cook Mushroom (ACM). His boss Matt gives him a pack of mushrooms and ask him to grade each mushroom according to its weight. Suppose the weight of a mushroom is w, then it’s grade s is s = 10000 - (100 - w)^2 What’s more, Ted also has to report the mode of the grade of these mushrooms. The mode is the value that appears most often. Mode may not be unique. If not all the value are the same but the frequencies of them are the same, there is no mode.
36100 100 100 99 98 1016100 100 100 99 99 1016100 100 98 99 99 97
Case #1:10000Case #2:Bad MushroomCase #3:9999 10000
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#define maxn 1000010using namespace std;int a[maxn];int vis[maxn];int s[maxn];int main() {int T;scanf("%d", &T);for (int h= 1; h <= T; h++) {int t;int N;int m = 0;scanf("%d", &N);memset(vis, 0, sizeof(vis));for (int i = 0; i < N; i++) {scanf("%d", &t);a[i] = 10000 - pow((100 - t), 2);vis[a[i]]++;if (m < vis[a[i]]) m = vis[a[i]];}int flag=0;sort(a, a + N);int j = 0;for (int i = 0; i < N; i++) {if (vis[a[i]] == m) {if (j == 0) {s[j] = a[i];j++;}else {if (a[i] != s[j - 1]) {s[j] = a[i];j++;}}}}if (m*j<N) flag = 1;if (j == 1) flag = 1;printf("Case #%d:\n", h);if (!flag) printf("Bad Mushroom\n");else {printf("%d", s[0]);for (int i = 1; i < j; i++) {if (s[i] != s[i - 1]) {printf(" %d", s[i]);}}printf("\n");}}}
0 0
- HDU5032--Grade
- grade
- hdu5032 Always Cook Mushroom
- zju2011:grade
- HDU5038-Grade
- hdu5038 Grade
- Grade HDU5038
- grade error
- Grade dependencies tree(grade 查依赖)
- pku3666_Making the Grade
- 1623. Sixth Grade Math
- hdu4207 Grade School Multiplication
- speed grade的选择
- Log of Grade Two
- 投资级别(Investment Grade)
- How to Grade Homeworks
- SEE YOU,GRADE TWO
- Grade 的分佈
- FileSystemWatcher触发多次Change事件的解决办法
- 轻论坛StartBBS、YouBBS、Xiuno对比
- 浅谈protocol buffer的使用
- ProgressBar总结
- Unity接入sdk时(和android交互),提示IOException错误解决方式。
- HDU5032--Grade
- code[vs] 1068乌龟棋(四维dp)
- iOS中property属性的关键字(史上最详解)
- 【蓝牙】蓝牙品牌使用指南
- 如何使用hbuilder快速生成一个直接打开网站的app
- 03.draggable 可被拖动插件 ,droppable 可容纳拖动插件 与resizable 可调整大小插件
- 数据挖掘--Outlines
- c#设计模式==策略模式
- EditText总结