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,则把这 ...
随机推荐
- Cheatsheet: 2013 12.17 ~ 12.31
.NET Introducing ASP.NET Web API Throttling handler C# async and await: A Deeper Dive PARALLEL PROGR ...
- js parseInt();parseFloat;Number()
1: parseInt( numString [, radix ] ) [测试浏览器:chromium && firefox] ①parseInt()函数用于将字符串转换为(十进制) ...
- include_path详细解析
include_path详细解析 原文地址:http://www.laruence.com/2010/05/04/1450.html 1.php默认的包含路径为 .;C:\php\pear 即 ...
- GBrowse配置相关资料
GBrowse配置相关资料(形状.颜色.配置.gff3) http://gmod.org/wiki/Glyphs_and_Glyph_Optionshttp://gmod.org/wiki/GBrow ...
- 针对各种浏览器css不兼容的写法
/*针对谷歌浏览器内核支持的CSS样式*/@media screen and (-webkit-min-device-pixel-ratio:0) { 样式 } /*针对IE6特制识别的CSS样式*/ ...
- shell应用——主控脚本实现(1)
shell脚本作用:内网ip,公网ip :cpu负载,内存使用量:ngix和mysql...
- 01_Spring概述
Spring概述 1.什么是Spring ? Spring是分层的JavaSE/EE full-stack(一站式) 轻量级开源框架 * JavaEE 程序在服务器端被分为三层(Web层[表现层].业 ...
- CALayer总结(三)
CPU VS GPU 动画和屏幕上组合的图层实际上被一个单独的进程管理,而不是你的应用程序.这个进程就是所谓的渲染服务.在iOS5和之前的版本是SpringBoard进程(同时管理着iOS的主屏).在 ...
- Java的内存分配策略
简单来说,对象内存分配主要是在堆中分配.但是分配的规则并不是固定的,取决于使用的收集器组合以及JVM内存相关参数的设定 以下介绍几条基本规则(使用的ParNew+Serial Old收集器组合): 一 ...
- THE SENSE OF BEAUTY
#include<stdio.h> int main() { ][] = { " ,.:;j", " ,: i. .,:;ff", " : ...