• acm icpc 北京网络赛 1007


    这道题感觉不需要考虑太多,直接写就好了,稍微看一下就知道 s=10000-(200-w)^2 在w=1-200中只可能有100种可能

    下面是ac代码:

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <cstdlib>
    #include <vector>

    using namespace std;

    int cot[10005];
    vector <int> ans;

    int main()
    {
        int t,n,w,s,maxn,num;
        while(scanf("%d",&t)!=EOF)
        {
            for(int i=1;i<=t;i++)
            {
                ans.clear();
                for(int j=1;j<=100;j++)
                {
                    s=j*(200-j);
                    cot[s]=0;
                }
                maxn=0;
                num=0;
                scanf("%d",&n);
                while(n--)
                {
                    scanf("%d",&w);
                    s=w*(200-w);
                    cot[s]++;
                    if(cot[s]==1)
                    {
                        num++;
                    }
                    if(maxn<cot[s])
                        maxn=cot[s];
                }
                for(int j=1;j<=100;j++)
                {
                    s=j*(200-j);
                    if(cot[s]==maxn)
                    {
                        ans.push_back(s);
                    }
                }
                printf("Case #%d: ",i);
                if(num==1)
                {
                    printf("%d ",ans[0]);
                }
                else if(ans.size()==num)
                {
                    printf("Bad Mushroom ");
                }
                else
                {
                    sort(ans.begin(),ans.end());
                    printf("%d",ans[0]);
                    for(int j=1;j<ans.size();j++)
                    {
                        printf(" %d",ans[j]);
                    }
                    printf(" ");
                }
            }
        }
        return 0;
    }


  • 相关阅读:
    java中的成员变量和局部变量
    多线程实现输出当前时间,和猜数字游戏
    JDBC
    jQuery和原生JS的对比
    JavaScript有趣的知识点
    MySQL的数据类型
    行级元素和块级元素
    重定向和请求转发的区别
    JSP九大内置对象
    Python练习
  • 原文地址:https://www.cnblogs.com/hqwhqwhq/p/4555895.html
Copyright © 2020-2023  润新知