A. MUH and Sticks
来源:互联网 发布:app inventor编程实例 编辑:程序博客网 时间:2024/04/29 11:17
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).
4 2 5 4 4 4
Bear
4 4 5 4 4 5
Elephant
1 2 3 4 5 6
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.
解题说明:此题判断棍子的长度,考虑是否有四根一样长的棍子,然后再判断剩下的棍子长度情况。
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<cstdlib>using namespace std;int main(){int b[10]={0},i,count=0,count1=0,count2=0,x;for(i=0;i<6;i++){scanf("%d",&x);b[x]++;}for(i=0;i<10;i++){if(b[i]>=4){count1=1;b[i]=b[i]-4;i--;}else if(b[i]==2){count2=1;}else{count=0;}}if(count1==1&&count2==1){printf("Elephant\n");}else if(count1==1){printf("Bear\n");}else{printf("Alien\n");}return 0;}
- A. MUH and Sticks
- A. MUH and Sticks(Codeforces Round #269)
- codeforces 471A MUH and Sticks
- cf471A MUH and Sticks
- Codeforces 269 (Div. 2) A. MUH and Sticks(水题)
- codeforces-#471A. MUH and Sticks(模拟)
- Codeforces Round #269 (Div. 2) A. MUH and Sticks
- codeforces 之 MUH and Sticks
- 【Codeforces Round 269 (Div 2)A】【简单讨论】MUH and Sticks 6根木棍拼动物
- A. Sasha and Sticks
- MUH and Cube Walls
- 【Codeforces Round 269 (Div 2)B】【简单构造】MUH and Sticks 数值升序输出三种可能编号序
- 【Codeforces Round 269 (Div 2)C】【暴力】MUH and Sticks 纸牌搭楼n张牌恰好搭楼数
- Codeforces Round #425 A. Sasha and Sticks
- CodeForce 832A Sasha and Sticks
- Sasha and Sticks (Codeforces 832A)
- codeforces 832A Sasha and Sticks
- cf471B MUH and Important Things
- passwordfile OS和密码认证
- SUSE linux 重置root密码图解步骤整理
- ucos 就绪表(Ready List)
- VM WorkStation 虚拟机中系统如何共享主机中的文件
- C++_系列自学课程_第_10_课_表达式_《C++ Primer 第四版》
- A. MUH and Sticks
- 你可能不知道的MySQL
- iscsi: 多路径
- 一个正则表达式的例子
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- Winpcap网络编程七之Winpcap学习教程,抓包,抓包!
- nginx之main函数的解读(一)
- first, firstly or at first
- Yii CDbCriteria 常用方法