hdu---(5038)Grade(胡搞)
Grade
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 109 Accepted Submission(s): 63
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.
The first line of each test cases contains one integers N (1<=N<=10^6),denoting the number of the mushroom.
The second line contains N integers, denoting the weight of each mushroom. The weight is greater than 0, and less than 200.
The first line contains "Case #x:", where x is the case number (starting from 1)
The second line contains the mode of the grade of the given
mushrooms. If there exists multiple modes, output them in ascending
order. If there exists no mode, output “Bad Mushroom”.
6
100 100 100 99 98 101
6
100 100 100 99 99 101
6
100 100 98 99 99 97
10000
Case #2:
Bad Mushroom
Case #3:
9999 10000
#include<cstdio>
#include<cstring>
int cnt[];
int main()
{
int w,cas,n,i,j;
scanf("%d",&cas);
for( i=;i<=cas;i++)
{
scanf("%d",&n);
memset(cnt,,sizeof(cnt));
for( j=;j<=n;j++)
{
scanf("%d",&w);
if(w>) w=-w;
cnt[w]++; //统计出现的频率
}
int maxc=; //最大频率
for( j=;j<=;j++)
if(cnt[maxc]<cnt[j])
maxc=j; printf("Case #%d:\n",i);
for( j=;j<=;j++)
if(cnt[j]<cnt[maxc]&&cnt[j]>) break; if(j>){
if(cnt[maxc]==n)
printf("%d\n",-(-maxc)*(-maxc));
else
printf("Bad Mushroom\n");
}
else
{
for( j=;j<=;j++)
if(cnt[maxc]==cnt[j]){
printf("%d",-(-j)*(-j));
j++;
break;
}
for( ;j<=;j++)
if(cnt[maxc]==cnt[j])
printf(" %d",-(-j)*(-j));
printf("\n");
}
}
return ;
}
hdu---(5038)Grade(胡搞)的更多相关文章
- HDU 5038 Grade(分级)
Description 题目描述 Ted is a employee of Always Cook Mushroom (ACM). His boss Matt gives him a pack of ...
- HDU 5038 Grade北京赛区网赛1005
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5038 解题报告:就是输入n个数w,定义s = 10000 - (100 - w)^2,问s出现频率最高 ...
- HDU 5038 Grade
解题思路:这题最关键的是要读懂题意,If not all the value are the same but the frequencies of them are the same, there ...
- HDU 5038 Grade (水题,坑题)
题意:给 n 个数,输出众数,但是如果所有的频率都相同但数不同输出 Bad Mushroom. 析:直接记录个数直接暴力就,就是要注意只有一种频率的时候. 代码如下: #pragma comment( ...
- HDU 4681 String 胡搞
设串C的第一个字母在串A中出现的位置是stA, 串C的最后一个字母在串A中出现的位置是edA. 设串C的第一个字母在串B中出现的位置是stB, 串C的最后一个字母在串B中出现的位置是edB. 求出每一 ...
- HDU 4690 EBCDIC (2013多校 1005题 胡搞题)
EBCDIC Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Su ...
- [LeetCode]Integer Break(Dp或胡搞或推公式)
343. Integer Break Given a positive integer n, break it into the sum of at least two positive intege ...
- 胡搞-强化版的light oj-1055-的思路-AI版的6重暴力For循环的BFS
新题目大意: 三个棋子按照先后顺序,可以随意方向合法地走到空位置上(而不是像原题light oj-1055中的一样三个棋子每次走的方向都一致),当三个棋子全部走进目标地点,就结束:求需要指挥的最少次数 ...
- hdu 5038 求出现次数最多的grade
http://acm.hdu.edu.cn/showproblem.php?pid=5038 模拟水题 求出现次数最多的grade.如果有多个grade出现的次数一样多,且还有其他的grade,则把这 ...
随机推荐
- 高仿bootstrap的layout效果(一)
公司研发一个新的cms,为了减少以后的修改和尽可能大程度的满足客户对cms的灵活需求,我的经理安排我去做一个与bootstrap的layout差不多的效果,这叫什么,锻炼的时候来了,加油,这个急不得一 ...
- Java_JDK_HashMap
(二)HashMap 需要注意的无非几点: 是什么结构,如何存储的? 如何加入元素?既然是hashMap,那么是如何计算hashcode的呢?遇到冲突又是如何解决的呢? 如何删除元素? 当容量不够时是 ...
- V-rep学习笔记:机器人逆运动学数值解法(Cyclic Coordinate Descent Method)
When performing inverse kinematics (IK) on a complicated bone chain, it can become too complex for a ...
- CentOS 6.5 64位 安装zabbix-2.2.0
安装环境: VM 10 + CentOS-6.5-x86_64-minimal 虚拟机网络是NAT方式, 动态IP Xshell登录到Centos操作 刚装的centos,啥都没有,先配一下yum 首 ...
- FJNU 1154 Fat Brother And His Love(胖哥与女神)
FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS Memory Limit: 257792K [Description] [ ...
- scala中如何编写自定义的流程控制结构
scala是一种函数式编程风格的语言,除了常见的if......else ,for ,while等传统的流程控制结构,也可以自定义流程控制的控制结构. 再了解scala如何实现编写新的流程结构,我们 ...
- kakfa源码编译打包
kakfa项目编译: cd /home/zhaofuxin/workspace/kafka-0.8.2.1-src ./gradlew releaseTarGz 会出现如下异常: zhaofuxin@ ...
- fFFmpeg 命令、案例、测试集中营
gitbook: https://www.gitbook.com/book/xdsnet/other-doc-cn-ffmpeg/details ffmpeg [全局选项] {[输入文件选项] -i ...
- default(T)的含义
default(T)是泛型中初始化的用法.因为对于泛型T你不知道是值类型还是引用类型,所以传参数是可能会出错.这里就要用到default(T). T t=default(T),就是初始化,值类型的话, ...
- mysql复制的配置
# 78服务器 server-id=78 # 从哪个数开始 auto_increment_offset=1 # 每次增加多少 auto_increment_increment=2 log-bin=m ...