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,则把这 ...
随机推荐
- UVA 11584 一 Partitioning by Palindromes
Partitioning by Palindromes Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %l ...
- Cheatsheet: 2014 01.01 ~ 01.14
.NET 15 reasons why I can't work without JetBrains ReSharper Web Web scraping with Node.js Koa.js : ...
- PHP中的替代语法(冒号、endif、endwhile、endfor)
我们经常在wordpress一类博客程序的模板里面看到很多奇怪的PHP语法,比如: <?php if(empty($GET_['a'])): ?> <font color=" ...
- css选择器选择顺序是从右往左的,为什么?
https://segmentfault.com/q/1010000000713509 为什么 CSS 选择器解析的时候是从右往左? CSS 的后代选择器本身就是一种在标准里面不那么推荐的方式. 首先 ...
- Quartz实用二三事
注意:本文项目使用的Quartz版本为2.2.1 一.关于Trigger Trigger tg = newTrigger().withIdentity("tg3", "g ...
- JavaWeb(一)
Web应用程序开发是目前软件开发领域的三大方向之一. 静态网页与动态网页 静态网页 表现形式:网页的内容是固定的,不会更新: 使用的技术:HTML,CSS 动态网页 表现形式:网页中的内容通过程序动态 ...
- Examples For When-Validate-Item trigger In Oracle Forms
The following example finds the commission plan in the COMMPLAN table, based on the current value of ...
- Spring的核心机制——依赖注入(Dependency Inject)
Spring不仅提供对象,还提供对象的属性值,而不是由使用该对象的程序所提供的. Java应用是由一些相互协作的对象所组成的,在Spring中这种相互协作的关系就叫依赖关系. 如果A组件调用了B组件的 ...
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- django(一)搭建开发环境
本学习系列均使用centos7操作系统,基于python3进行操作.centos7下的python3安装配置http://www.cnblogs.com/Guido-admirers/p/625941 ...