zoukankan      html  css  js  c++  java
  • SDUSTOJ T1587 YES! YOU CAN!

    YES! YOU CAN!

    Time Limit: 1 Sec  Memory Limit: 128 MB

    Description

    Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way:
    Four sticks represent the animal's legs, these sticks should have the same length.
    Two remaining sticks represent the animal's head and body. The bear's head stick must be shorter than the body stick. The elephant, however, has a long trunk, so his head stick must be as long as the body stick. Note that there are no limits on the relations between the leg sticks and the head and body sticks.
    Your task is to find out which animal can be made from the given stick set. The zoo keeper wants the sticks back after the game, so they must never be broken, even bears understand it.

    Input

    There are multiple test cases.

    In each test case, there's a single line containing six space-separated integers li (1≤li≤9) — the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks.

    Output

    If you can make a bear from the given set, print string "Bear" (without the quotes). If you can make an elephant, print string "Elephant" (wthout the quotes). If you can make neither a bear nor an elephant, print string "Alien" (without the quotes).

    Sample Input

    4 2 5 4 4 4

    Sample Output

    Bear



    分析:这是第一次在OJ上做ACM的题目,感觉ACM的题目都很多隐含的细节,并且题目中只提供了一个案例,其他条件需要自己的深度挖掘。   首先存储六个数,然后用数组统计每个数的出现的次数,然后对此数进行分析。如果没有一个数超过四次,直接输出Alien;有超过四次的数,减去四次,分析剩余的2个的情况。如果两个相同,即为Elephant,否则为Bear。




    #include<stdio.h>
     
    int main()
    {
        int num[6];
        int flag;
        while(scanf("%d %d %d %d %d %d",&num[0],&num[1],&num[2],&num[3],&num[4],&num[5])!=EOF)
        {
            int count[10]= {0,0,0,0,0,0,0,0,0,0};
            int i,j,k;
            flag = 0;
     
            for(k=0; k<6; k++)
                count[num[k]]++;
     
            for(i=1; i<10; i++)
            {
                if(count[i]>=4)
                {
                    count[i] -= 4;
                    for(j=1; j<10; j++)
                    {
                        if(count[j]==2)
                        {
                            printf("Elephant
    ");
                            flag = 1;
                            break;
                        }
                    }
                    for(j=0; j<10; j++)
                    {
                        if(count[j]==1)
                        {
                            printf("Bear
    ");
                            flag = 1;
                            break;
                        }
                    }
                }
            }
            if(!flag)
                printf("Alien
    ");
        }
        return 0;
    }

    这是第一次做ACM的题目,如有Bug请指正。

  • 相关阅读:
    利用别名切换索引流程Elasticsearch 7.7
    关于误删除elasticSearch 索引,怎么能快速找回?
    总结traefik 在k8s 环境中的配置文件
    ES ElasticSearch 7.x 下动态扩大索引的shard数量
    Java框架Spring Boot & 服务治理框架Dubbo & 应用容器引擎Docker 实现微服务发布
    谈一下Docker与Kubernetes集群的日志和日志管理-转载
    Elasticsearch优化 & filebeat配置文件优化 & logstash格式配置 & grok实践
    Nginx错误日志(error_log)配置及信息详解
    赵总的运维体系专栏学习的总结
    APP或者前端通过识别用户代理详细信息和浏览器数据进行安全防御
  • 原文地址:https://www.cnblogs.com/kunsoft/p/5312816.html
Copyright © 2011-2022 走看看