cf471A MUH and Sticks
1 second
256 megabytes
standard input
standard output
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.
sb模拟题
唯一的难点是……cf太卡交都交不上去
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<set>
#define LL long long
using namespace std;
inline LL 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;
}
LL a[10];
LL n,aa,bb;
LL s,mx,saves=-1;
int main()
{
for (int i=1;i<=6;i++)a[i]=read();
sort(a+1,a+7);
for (int i=1;i<=6;i++)
{
if(a[i]==a[i-1]||i==1)s++;
else s=1;
if(s==4) saves=a[i];
mx=max(mx,s);
}
if (mx<4)
{
printf("Alien\n");
return 0;
}
if (mx==6)
{
printf("Elephant\n");
return 0;
}
if (mx==5)
{
printf("Bear\n");
return 0;
}
for(int i=1;i<=6;i++)
if (a[i]!=saves)
{
if (!aa) aa=a[i];
else bb=a[i];
}
if (aa!=bb)
{printf("Bear\n");
}else printf("Elephant\n");
}
cf471A MUH and Sticks的更多相关文章
- 【CodeForces 471A】MUH and Sticks
题 题意 给你六根木棍的长度,熊需要头比身体短,大象需要头和身体一样,四肢要一样长,否则就是外星人.请你判断能组成哪一个. 分析 暴力,循环看一下每根有几根相同的,然后如果有四根都是有四根相同的&am ...
- [CodeForces 471A] MUH and Sticks
题目链接:http://codeforces.com/problemset/problem/471/A 题目数据规模1 - 9,可以用一个数组进行计数,减掉出现四次的数,看看还有几个是非零数,有一个就 ...
- HDOJ 1051. Wooden Sticks 贪心 结构体排序
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- POJ 2653 Pick-up sticks (线段相交)
题意:给你n条线段依次放到二维平面上,问最后有哪些没与前面的线段相交,即它是顶上的线段 题解:数据弱,正向纯模拟可过 但是有一个陷阱:如果我们从后面向前枚举,找与前面哪些相交,再删除前面那些相交的线段 ...
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- POJ 2653 Pick-up sticks【线段相交】
题意:n根木棍随意摆放在一个平面上,问放在最上面的木棍是哪些. 思路:线段相交,因为题目说最多有1000根在最上面.所以从后往前处理,直到木棍没了或者最上面的木棍的总数大于1000. #include ...
- POJ1065Wooden Sticks[DP LIS]
Wooden Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21902 Accepted: 9353 De ...
- 【POJ 2653】Pick-up sticks 判断线段相交
一定要注意位运算的优先级!!!我被这个卡了好久 判断线段相交模板题. 叉积,点积,规范相交,非规范相交的简单模板 用了“链表”优化之后还是$O(n^2)$的暴力,可是为什么能过$10^5$的数据? # ...
- CF451A Game With Sticks 水题
Codeforces Round #258 (Div. 2) Game With Sticks A. Game With Sticks time limit per test 1 second mem ...
随机推荐
- /proc/uptime
在Linux中,我们常常会使用到uptime命令去看看系统的运行时间,它与一个文件有关,就是/proc/uptime.这个文件里的两个参数所代表的意义如下. [root@app ~]#cat /pro ...
- C#中,表达式的计算遵循一个规律:从左到右依次计算。
int i = 0; int j = (i++)+(i++)=(i++)+i=i+++i=i+++i++=1;
- python高级编程之描述符与属性02
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' #元描述符 #特点是:使用宿主类的一个或者多个方法来执行一个任务,可 ...
- python之路-模块 WebDriver API
相关文档: http://selenium-python.readthedocs.org/en/latest/api.html#selenium.common.exceptions.InvalidEl ...
- (36)JS运动之使物体向右运动
基本思路:样式要是绝对定位,不然的话根本走不起来.当开启一个定时器的时候.必须先清除定时器.这是为了防止鼠标连续点击button而开启多个定时器,导致物体的速度加快等原因,其次要控制好物体的运动和停止 ...
- Webstrom 使用过程中遇到的问题以及解决方案
作为一个前端开发,我用过webstorm和sublime两个编辑器.sublime小巧轻便,不耗内存.但是webstorm具有以下特点,让我难以舍弃. webstorm优点 点击一个函数名,它会跳到函 ...
- CSS---------------之文本颜色
CSS2支持如下名字的颜色 注意点: 你的浏览器有可能支持更多名字,但是在实际用的过程中尽量少使用名字的,因为各个浏览器对颜色的会存在差异:查看颜色可以参考 对于更多地颜色,你可以使用代表红,绿,蓝三 ...
- C# 文件操作(一)
1.说明: 写入文件内容,如果文件中有内容,则进行追加,目录是程序集下的目录 public static void WriteLog(string value) { try { //目录是程序集下的D ...
- hdu2037 经典贪心入门
今年暑假不AC Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- Gengxin讲STL系列目录
引言:有人催我写关于STL的博客#(滑稽) STL嘛,昨晚有人一直逼问我STL名字的由来——STL = Standard Template Library,标准模板库,惠普实验室开发的一 ...