Balanced Game

本文探讨了如何根据物品数量设计出平衡的游戏规则,例如经典的石头剪刀布游戏及其扩展版。通过分析得出结论,当物品数量为奇数时,才能形成相互制约的平衡状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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\%50% no matter how the other one plays (if there is a tie, repeat this game until someone wins). Given an integer NN, representing the count of shapes in a game. You need to find out if there exist a rule to make this game balanced.

Input Format

The first line of input contains an integer tt, the number of test cases. tt test cases follow.

For each test case, there is only one line with an integer N (2\le N\le 1000)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 Format

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

样例输入

3
2
3
5

样例输出

Bad
Balanced
Balanced

题目来源

ACM-ICPC 2016 Qingdao Preliminary Contest

题意:

判断一个数所代表的物品能否形成平衡的关系,就像石头剪刀布;

分析:

一个数要想形成平衡的,除了自己之外,需要对其他剩余的数一半是制约一半是被制约,也就是偶数,因此只要总数为奇数即可;

代码:

#include<stdio.h>
using namespace std;
int n,t,m;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
            scanf("%d",&n);
            if(n&1)
                printf("Balanced\n");
            else
                printf("Bad\n");
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值