「CF471A」MUH and Sticks
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.
The single line contains 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.
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” (wıthout the quotes). If you can make neither a bear nor an elephant, print string “Alien” (without the quotes).
1 |
4 2 5 4 4 4 |
1 |
Bear |
1 |
4 4 5 4 4 5 |
1 |
Elephant |
1 |
1 2 3 4 5 6 |
1 |
Alien |
If you’re out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue.
题解
模拟。。统计个数讨论。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #include<set> #include<map> #define pa pair<int,int> #define inf 1000000000 #define ll long long using namespace std; inline int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int a[7]; int x,y,z; int nx,ny,nz; int main() { for(int i=1;i<=6;i++)a[i]=read(); x=a[1]; for(int i=1;i<=6;i++)if(a[i]!=x)y=a[i]; for(int i=1;i<=6;i++)if(a[i]!=x&&a[i]!=y)z=a[i]; for(int i=1;i<=6;i++) if(a[i]==x)nx++; else if(a[i]==y)ny++; else if(a[i]==z)nz++; if(nx+ny+nz!=6||(nx<=3&&ny<=3&&nz<=3))puts("Alien"); else if(nx==6||ny==6||nz==6)puts("Elephant"); else if((nx==4||ny==4||nz==4)&&(nx*ny*nz==0))puts("Elephant"); else puts("Bear"); return 0; } |