Balanced Game

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 115    Accepted Submission(s): 99

Problem Description

Rock-paper-scissors is a zero-sum hand game usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are "rock", "paper", and "scissors". The game has only three possible outcomes other than a tie: a player who decides to play rock will beat another player who has chosen scissors ("rock crushes scissors") but will lose to one who has played paper ("paper covers rock"); a play of paper will lose to a play of scissors ("scissors cut paper"). If both players choose the same shape, the game is tied and is usually immediately replayed to break the tie.

Recently, there is a upgraded edition of this game: rock-paper-scissors-Spock-lizard, in which there are totally five shapes. The rule is simple: scissors cuts paper; paper covers rock; rock crushes lizard; lizard poisons Spock; Spock smashes scissors; scissors decapitates lizard; lizard eats paper; paper disproves Spock; Spock vaporizes rock; and as it always has, rock crushes scissors.

Both rock-paper-scissors and rock-paper-scissors-Spock-lizard are balanced games. Because there does not exist a strategy which is better than another. In other words, if one chooses shapes randomly, the possibility he or she wins is exactly 50% no matter how the other one plays (if there is a tie, repeat this game until someone wins). Given an integer N, representing the count of shapes in a game. You need to find out if there exist a rule to make this game balanced.

 

Input

The first line of input contains an integer t, the number of test cases. t test cases follow.
For each test case, there is only one line with an integer N (2≤N≤1000), as described above.

Here is the sample explanation.

In the first case, donate two shapes as A and B. There are only two kind of rules: A defeats B, or B defeats A. Obviously, in both situation, one shapes is better than another. Consequently, this game is not balanced.

In the second case, donate two shapes as A, B and C. If A defeats B, B defeats C, and C defeats A, this game is balanced. This is also the same as rock-paper-scissors.

In the third case, it is easy to set a rule according to that of rock-paper-scissors-Spock-lizard.

 

Output

For each test cases, output "Balanced" if there exist a rule to make the game balanced, otherwise output "Bad".
 

Sample Input

3
2
3
5
 

Sample Output

Bad
Balanced
Balanced
 

Source

 
签到水题
思路:把一个形状抽象成一个点,要与其他所有点有向相连,出度为胜,入度为负,只有当入度与出度相等,即胜负概率相同,才为平衡。故有奇数个形状平衡,偶数不平衡。
 //2016.9.17
#include <iostream>
#include <cstdio> using namespace std; int main()
{
int T, n;
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
if(n&)printf("Balanced\n");
else printf("Bad\n");
} return ;
}

HDU5882的更多相关文章

  1. hdu5882 Balanced Game

    题目链接:hdu5882 Balanced Game 题解:每种手势的攻防数一样,不难想到n为奇数时游戏平衡. #include<cstdio> #include<cstring&g ...

  2. 2016 ACM/ICPC Asia Regional Qingdao Online HDU5882

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=5882 解法:一个点必须出度和入度相同就满足题意,所以加上本身就是判断奇偶性 #include<std ...

随机推荐

  1. linux下查看cpu物理个数和逻辑个数 - chw1989的专栏 - 博客频道 - CSDN.NET

    body { font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLi ...

  2. cakephp 2.0 源码解读(一)

    lib - Cake -basic.php -bootstrap.php -Cache -Config -Configure -Controller -Core -Error -Event -I18n ...

  3. losbyday Linux查找命令

    PS:第一次发表博客,试一下水,晚一点修改文本格式 linux下的命令都存放在/bin /sbin /usr/bin /usr/sbin路径下等echo $PATH which 是用来查询命令存放的路 ...

  4. soot的安安装与使用

    soot 工具是一个可以分析多种源代码的工具,可以进行插桩,最新版本可对android apk文件,进行相应的分析以往可以直接在eclipse里面在线安装. soot(A framework for  ...

  5. (中等) POJ 1084 Square Destroyer , DLX+可重复覆盖。

    Description The left figure below shows a complete 3*3 grid made with 2*(3*4) (=24) matchsticks. The ...

  6. css padding和margin的百分比

    前段时间我同事对于margin和padding应用百分比值似乎有些误解,觉得可能是个普遍问题,所以觉得有必要拿出来单独写一下. margin和padding都可以使用百分比值的,但有一点可能和通常的想 ...

  7. AFNetWorking发送post请求,Code=-1016错误

    使用AFNetWorking发送post请求时,可能会出现下面Code=-1016问题.打印的error如下: Error:Error Domain=com.alamofire.error.seria ...

  8. Memcached源码分析

    作者:Calix,转载请注明出处:http://calixwu.com 最近研究了一下memcached的源码,在这里系统总结了一下笔记和理解,写了几 篇源码分析和大家分享,整个系列分为“结构篇”和“ ...

  9. DWR3.0框架入门(3) —— ScriptSession的维护及优化

    1.ScriptSession使用中存在的问题        在上一节实现了服务器的推送功能,但是根据 ScriptSession的生命周期我们可以得出以下几点的问题:   (1)ScriptSess ...

  10. Badboy安装与使用

    Badboy是一个录制web脚本的工具 1.下载Badboy:http://www.badboy.com.au/download/add 2.启动Badboy,认识主界面 3.使用Badboy录制we ...