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\n");
                        flag = 1;
                        break;
                    }
                }
                for(j=0; j<10; j++)
                {
                    if(count[j]==1)
                    {
                        printf("Bear\n");
                        flag = 1;
                        break;
                    }
                }
            }
        }
        if(!flag)
            printf("Alien\n");
    }
    return 0;
}

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值