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,则把这 ...
随机推荐
- heredoc 和 nowdoc
heredoc 和 nowdoc 多次使用 php nowdoc HereDoc 插入大量Hmtl都没有成功,一样提示语法有问题,事实上PHP手册注明是这样写的,实在很奇怪 最后发现了问题所在 ...
- [51NOD1405] 树的距离之和(树DP)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1405 (1)我们给树规定一个根.假设所有节点编号是0-(n-1 ...
- Sqlite 学习记录
Sqlite命令行(CLP)====================================================================================== ...
- 《Linux内核设计的艺术》学习笔记(六)执行setup.s
参考资料 1. 8259A可编程中断控制器 jmpi , SETUPSEG // 0x90200 到这里,bootsect.s的执行就算结束了.控制权转移到了setup.s文件的手中. setup程序 ...
- android测试参考,及CreateProcess failure, error问题解决
今天小伙伴问我问题,我给了这2个小命令,或许做android测试的同学可以用得着. 截图命令adb shell /system/bin/screencap -p /sdcard/screenshot. ...
- 容易混淆的url src href
新手刚学习的时候会分不清 url src href这些,不知道什么情况下应该用哪个.现在让我来理一理. url 统一资源定位符是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示,是互联网 ...
- LINQ之路 2:C# 3.0的语言功能(上)
在上一篇的LINQ介绍中,我们已经看到了隐式类型变量var,扩展方法(extension method)和lambda表达式的身影.没错,他们正是LINQ技术的基石,是他们让LINQ的实现成为可能,并 ...
- Oracle VM VirtualBox 虚拟机与主机共享文件
安装增强功能(参考文档) VirtualBox自带了一个增强工具Sun VirtualBox Guest Additions,这是实现虚拟机与真实主机共享的关键.启动虚拟机后,点击控制菜单“设备”→“ ...
- XML命名空间详解
http://happylongnv.blog.hexun.com/48859954_d.html 目的:解决同一个元素在相同文件中代表不同含义的问题.因为XML文档中使用的元素不是固定的,那么两个不 ...
- 直播未来属于RTMP还是HTTP?
直播未来属于RTMP还是HTTP? HTTP 传视频比 RTMP 实现起来简单?HTTP 延迟太高? 答:直播通讯未来是属于html5的. 1,协议使用份额 如今国内90%的面向大众的直播平台都是采用 ...