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. IGeoFeatureLayer

    Members   All Properties Methods Inherited Non-inherited Description AnnotationProperties Annotation ...

  2. PAT 天梯赛 L2-004 这是二叉搜索树吗?

    递归判断+建树 题目链接:https://www.patest.cn/contests/gplt/L2-004 题解 二叉搜索树的特点就是其根节点的值是位于左右子树之间的,即大于左子树的所有值,但是小 ...

  3. word采用尾注进行参考文献排版的一些问题

    使用Word中尾注的功能可以很好地解决论文中参考文献的排序问题.方法如下: 1.光标移到要插入参考文献的地方,菜单中“插入”——“引用”——“脚注和尾注”. 2.对话框中选择“尾注”,编号方式选“自动 ...

  4. Python+Selenium+PhantomJS下载JavaScript异步加载网页

    # -*- coding: utf-8 -*- from selenium import webdriver import selenium.webdriver.support.ui as ui fr ...

  5. Hibernate批量提交

    的 批量插入(Batch inserts) 如果要将很多对象持久化,你必须通过经常的调用 flush() 以及稍后调用 clear() 来控制第一级缓存的大小. Session session = s ...

  6. frame间跳转及相关问题

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  7. 安装PIL遇到的问题

    配置:Win7 64位 不过折腾到最后,没有使用PIL,官方的PIL很久木有更新了,换了Pillow,是PIL的衍生吧,一直有更新,但是两者不可在同一环境共存. 1 Python version 2. ...

  8. (中等) POJ 1191 棋盘分割,DP。

    Description 将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同最后剩下的矩形棋盘共有n块矩形棋盘.(每次 ...

  9. (简单) POJ 1062 昂贵的聘礼,Dijkstra。

    Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家 拿不出这么多金币,便请求酋长降 ...

  10. checkbox选择多数据传入后台时,怎样解析数据

    <input type="checkbox" name="test" value="值1" />显示的内容<input t ...