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. Selenuim+Python之元素定位总结及实例说明

    网页自动化最基本的要求就是要定位到各个元素,然后才能对该元素进行各种操作(输入,点击,清除,提交等),所以笔者今天来总结下Selenuim+Python最基本的几种定位方式及实例说明,希望能帮助到大家 ...

  2. Codeforces #377 Div2

    打得还不错的一场CF,题目质量也很高,今后还要继续努力 A题: 题意:给定一个数k,让其乘一个最小的数,使乘得以后的数要不被10整除,要不减去r以后被10整除,求这个最小的数 #include < ...

  3. 制作win10 usb 启动盘

    Rufus 是一个开源的USB启动盘制作程序.其特点就是快速,且支持各种系统,包括各种windows系统,linux系统,使用也很简单. Rufus主页: http://rufus.akeo.ie/ ...

  4. ELK 日志分析体系

    ELK   日志分析体系 ELK 是指 Elasticsearch.Logstash.Kibana三个开源软件的组合. logstash                       负责日志的收集,处 ...

  5. LVS+Keppalived实现高可用负载均衡

    三.LVS Keppalived的安装 3.1.环境描述 LVS server1 (Master):10.0.0.202 虚拟IP为:10.0.0.210 LVS server2 ( Slave ) ...

  6. XML&AJAX

    AJAX: Asynchronous Javascript and XML 1. 客户端触发异步操作 2. 创建新的XMLHttpRequest, 是重要的js对象,通过它提起对服务器端的请求 3. ...

  7. POJ3255次短路

    POJ3255 题意:给定一个图,求从1到n的次短路 分析:我们需要在dijkstra上作出一些修改,首先,到某个顶点v的次短路要么是到其他某个顶点u的最短路在加上u到v的边,要么是到v的次短路再加上 ...

  8. matlab find函数

    find函数用来获取向量或矩阵中非0元素的索引 假设X是行向量,则find(X)返回的是一个行向量:X'为列向量,find(X')返回的是一个列向量. 看一个例子:A是一个行向量,B是一个列向量,将B ...

  9. MPU6050程序(转)

    源:MPU6050程序 初始化定义 #ifndef _MPU6050_H #define _MPU6050_H #define PORT_USED 0 #define MPU6050_ADDRESS_ ...

  10. 路由器、交换机学习之IP地址、使用网络掩码划分子网

    局域网子网划分 对于C类IP地址来说(192.168.1.X,其中前面的192.168.1为网络号,后面的X为主机号,这样的网络中可以有254台主机,其中.0为局域网地址,.255为广播地址)进行子网 ...