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,则把这 ...
随机推荐
- HDU 4870 Rating 概率DP
Rating Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- linux挂载共享文件夹
挂载windows共享目录或FTP: 方式一:包含密码 Shell代码 收藏代码 sudo mount //192.168.10.22/FTPServer /windows -o username=u ...
- 读写分离提高 SQL Server 并发性能
以下内容均非原创,仅作学习.分享!! 在 一些大型的网站或者应用中,单台的SQL Server 服务器可能难以支撑非常大的访问压力.很多人在这时候,第一个想到的就是一个解决性能问题的利器——负载均衡. ...
- eclipse 设置jvm 内存
Eclipse 中设置JVM 内存 今天在eclipse 中测试把文档转换为图片的时候,报出了下面的错误: java.lang.OutOfMemoryError: Java heap space 从上 ...
- DOM解析XML练习
首先以XML文件存储数据,格式如下(作为数据库) exam.xml <?xml version="1.0" encoding="UTF-8" standa ...
- TreeView控件
public partial class WebForm1 : System.Web.UI.Page { DataSet dsTreeView = new DataSet(); protected v ...
- 使用xml来显示获取的mysql数据
mysql test -u test -X -e 'select * from employees where empid = 1' 其中 -X 就是以xml形式显示
- Spring 自动装配 Bean
Spring3系列8- Spring 自动装配 Bean 1. Auto-Wiring ‘no’ 2. Auto-Wiring ‘byName’ 3. Auto-Wiri ...
- [转载] zookeeper 事件通知
ZK事件回调当一个client访问ZK时,client与ZK保持长连接.应用可以通过client的api注册一些callback,当对应的事件发生时,client会执行对应的callback.如果你基 ...
- 几种HtmlEncode的区别(转)
一.C#中的编码 HttpUtility.HtmlDecode.HttpUtility.HtmlEncode与Server.HtmlDecode.Server.HtmlEncode与HttpServe ...