hdn5038好坏蘑菇

</pre>Grade</h1><strong><span style="font-family:Arial; color:green">Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 801    Accepted Submission(s): 399</span></strong><div class="panel_title" align="left" style="height:38px; padding:0px 14px; color:rgb(124,169,237); font-size:18px; font-family:Arial; font-weight:bold">Problem Description</div><div class="panel_content" style="height:auto; margin:0px; padding:0px 20px; font-size:14px; font-family:'Times New Roman'; text-align:left">Ted is a employee of Always Cook Mushroom (ACM). His boss Matt gives 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 <center><strong>s = 10000 - (100 - w)^2</strong></center>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.</div><div class="panel_bottom" style="height:auto; margin:0px"> </div><div class="panel_title" align="left" style="height:38px; padding:0px 14px; color:rgb(124,169,237); font-size:18px; font-family:Arial; font-weight:bold">Input</div><div class="panel_content" style="height:auto; margin:0px; padding:0px 20px; font-size:14px; font-family:'Times New Roman'; text-align:left">The first line of the input contains an integer T, denoting the number of testcases. Then T test cases follow.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.</div><div class="panel_bottom" style="height:auto; margin:0px"> </div><div class="panel_title" align="left" style="height:38px; padding:0px 14px; color:rgb(124,169,237); font-size:18px; font-family:Arial; font-weight:bold">Output</div><div class="panel_content" style="height:auto; margin:0px; padding:0px 20px; font-size:14px; font-family:'Times New Roman'; text-align:left">For each test case, output 2 lines.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”.</div><div class="panel_bottom" style="height:auto; margin:0px"> </div><div class="panel_title" align="left" style="height:38px; padding:0px 14px; color:rgb(124,169,237); font-size:18px; font-family:Arial; font-weight:bold">Sample Input</div><div class="panel_content" style="height:auto; margin:0px; padding:0px 20px; font-size:14px; font-family:'Times New Roman'; text-align:left"><pre style="word-wrap:break-word; white-space:pre-wrap; margin-top:0px; margin-bottom:0px"><div style="font-family:'Courier New',Courier,monospace">3
6
100 100 100 99 98 101
6
100 100 100 99 99 101
6
100 100 98 99 99 97</div>
 

Sample Output
       
       
Case #1: 10000 Case #2: Bad Mushroom Case #3: 9999 10000
 


题目就是要根据输入的w值,来算出s值,并把输出频率最多的s值(可以为多组),但如果出现多组频率s值,并且总数的等于输入的总数,则判为坏蘑菇;(比如有6组w,s值分别为1000、1000、999、999、998、998,平率相等的有3组,并且总数为6,则为坏蘑菇)

#include <stdio.h>
#include <math.h>
#include <algorithm>
int main()
{
    int n,w,i,m,d,t,max,c,sign,k,a[110];
    while(scanf("%d",&n)!=EOF)
    {
        t=0;
        while(n--)
        {
        memset(a,0,sizeof(a));
        scanf("%d",&m);
            t++;
           max=-1;
           c=0;
           sign=0;
             k=m;
            while(m--)
            {
                scanf("%d",&w);
                a[abs(100-w)]++;
            }
            for(i=0;i<=100;i++)
            {
                if(a[i]>max)  max=a[i];
            }
            for(i=0;i<=101;i++)
            {
                if(a[i]==max) c++;
            } 
            printf("Case #%d:\n",t); 
                 if(max*c==k&&c!=1)
                    printf("Bad Mushroom");
                else
                {
                    for(i=100;i>=0;i--)
                    { 
                      if(a[i]==max) 
                      {
                          if(sign==0)
                        {
                          printf("%d", 10000-i*i);
                          sign=1;
                        }
                       else    printf(" %d",10000-i*i);
                      }
                    } 
                }
                    
            printf("\n");
        }
    }
    return 0;
}



内容概要:该题库专为研究生入学考试计算机组成原理科目设计,涵盖名校考研真题、经典教材课后习题、章节题库和模拟试题四大核心模块。名校考研真题精选多所知名高校的计算机组成原理科目及计算机联考真题,并提供详尽解析,帮助考生把握考研命题趋势与难度。经典教材课后习题包括白中英《计算机组成原理》(第5版)和唐朔飞《计算机组成原理》(第2版)的全部课后习题解答,这两部教材被众多名校列为考研指定参考书目。章节题库精选代表性考题,注重基础知识与重难点内容,帮助考生全面掌握考试大纲要求的知识点。模拟试题依据历年考研真题命题规律和热门考点,精心编制两套全真模拟试题,并附标准答案,帮助考生检验学习成果,评估应试能力。 适用人群:计划参加研究生入学考试并报考计算机组成原理科目的考生,尤其是需要系统复习和强化训练的学生。 使用场景及目标:①通过研读名校考研真题,考生可以准确把握考研命题趋势与难度,有效评估复习成效;②通过经典教材课后习题的练习,考生可以巩固基础知识,掌握解题技巧;③通过章节题库的系统练习,考生可以全面掌握考试大纲要求的各个知识点,为备考打下坚实基础;④通过模拟试题的测试,考生可以检验学习成果,评估应试能力,为正式考试做好充分准备。 其他说明:该题库不仅提供详细的题目解析,还涵盖了计算机组成原理的各个方面,包括计算机系统概述、数据表示与运算、存储器分层、指令系统、中央处理器、总线系统和输入输出系统等。考生在使用过程中应结合理论学习与实践操作,注重理解与应用,以提高应试能力和专业知识水平。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值