题干:

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

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)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

题目大意:

剪刀石头布(这三种操作)会使得每个人都有50%的胜率(如果两人操作相同则重新这一回合)

现在已知有n种操作,问这n种操作能否使得每种操作的胜率为50%。

解题报告:

如果把操作看成点,之间的关系看成边,那么在剩余n-1个顶点中需要有一半指向自己,一半由自己指向,所以n-1需要是偶数,n需要是奇数,由此得到了一个可以输出Balanced的必要条件(也就是如果要是Balance的,那就必须n是奇数)。

现在来证明n是奇数,那么一定能构造出来一个Balance的解,也就是充分条件(wjh大佬tql)。(因为每两个顶点之间只能有一条有向边(因为不可能我比你强的同时你也比我强)所以有可能构造不出来,所以需要证明一定可以构造出来)对于n个操作的,自然不好构造,但是我们可以用数学归纳法类似的思想,由小及大。对于三个操作的,比如石头剪刀布,一定可以构造吧,然后在此基础上加两个顶点,那么这两个顶点和那三个顶点之间没有任何关系(可以随意连边),所以我们:这两个顶点之间连一条边(谁到谁的都行),然后这两个点和剩下的顶点根据情况连边一定可以构造出来。以此往复,就可以构造出来任意奇数个操作的可行解了。重点就是已知三个点是可以构造的,然后依次加两个点也能构造,然后就可以证明了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;int main()
{int t,n;cin>>t;while(t--) {scanf("%d",&n);if(n % 2 == 1) {puts("Balanced");}else puts("Bad");}return 0 ;
}

【HDU - 5882】Balanced Game (找规律,思维)相关推荐

  1. HDU 5963 朋友(找规律)

    朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submiss ...

  2. HDU 5882 Balanced Game(2016亚洲区青岛站网络赛)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5882 水题,直接奇偶性判断即可. #include <cstdio> #inc ...

  3. 牛客 - 丁姐姐喜欢Fibonacci(找规律+思维)

    题目链接:点击查看 题目大意:给出一个正整数n,求第n项斐波那契数列的奇偶性 题目分析:这个题..看到1e15的数据范围,第一反应就是去敲一个矩阵快速幂的模板,但发现题目没有给取模范围,所以还用不了矩 ...

  4. HDU 6229 Wandering Robots 找规律+离散化

    题目链接:Wandering Robots 题解:先讲一下规律,对于每一个格子它可以从多少个地方来有一个值(可以从自己到自己),然后答案就是统计合法格子上的数与所有格子的数的比值 比如说样例的3 0格 ...

  5. HDU - 6267 (概论/找规律/递推)

    VJ地址 题目大意: 有n个节点 从0-(n-1),连边的规律为 即i点的父亲只能是比i小的数,而且是随机的,现在随机选择应该一个节点作为根,求这子树的和的期望是多少. 思路:可以知道总共有(n-1) ...

  6. HDU 5882 Balanced Game 分析+欧拉图

    题意 就是把判断有五个姿态的剪子包袱锤游戏其中能否平局 分析 .... code ## /*本题的正确逻辑是分析出图中要求的是个欧拉图因为每个点的入度等于出度每个点的攻防数目都一样所以可以把当前有向欧 ...

  7. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  8. HDU ACM 1046 Gridland 找规律

    分析:给出一个矩阵.问最短从一个点经过全部点以此回到起点的长度是多少.绘图非常好理解.先画3*4.3*3.4*4的点阵图案.试着在上面用最短路走一走,能够发现当矩形点阵的长宽都是奇数时,最短路中必然有 ...

  9. hdu 4506(快速幂+找规律)

    小明系列故事--师兄帮帮忙 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Pr ...

  10. 数学--数论--HDU - 6322 打表找规律

    In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n ...

最新文章

  1. 非标自动化企业前十名_非标自动化设计:非标自动化是如何被称做企业里的血液?...
  2. 梯度下降算法的正确步骤是什么?
  3. HDOJ 1175 连连看 DFS
  4. Unity学习笔记4 更换编辑器为VS2013及VS的背景图片设置
  5. pythoncharm安装时出错误_python01:pycharm中安装包时所遇到的问题
  6. 李焕英是如何从不被看好到碾压唐探3的?
  7. java单例枚举_Java增强枚举的用例
  8. scanf函数详解(下)
  9. 应用电子技术插计算机科学,插本专业大全
  10. 为转型绞尽脑汁,新东方到美国教中文!网友:卷到国外去了
  11. C++ 动态连接库使用
  12. 树莓派做微信公众号服务器,树莓派与微信公众号对接(python)
  13. 手写HashMap排序
  14. 信号与系统实验二 信号运算的MATLAB 实验
  15. 如何从UCI获取数据集?
  16. Scrapy爬取拉钩网的爬虫(爬取整站CrawlSpider)
  17. RFC 文档(1-500)
  18. simulink方框_simulink模型引用
  19. 音乐播放器mplayer的简单使用
  20. scss exceeded maximum budget. Budget 4.00 kB was not met by 130 bytes with a total of 4.13 kB.

热门文章

  1. Ubuntu开机自动启动script(2)
  2. 数据结构与算法总结(完结)
  3. [密码学基础][每个信息安全博士生应该知道的52件事][Bristol52]49.描述在IPsec和TLS后的基本想法
  4. python基础公式_一、Python基础(数据类型、基本函数、基本运算)
  5. html 分页_JQuery堪称完美的分页函数
  6. java gb13000 ucs2_采用GB 13000的UCS-2进行存储的文件怎么转换
  7. 基于结构体的二进制文件读写
  8. php中介者,PHP设计模式 - 中介者模式
  9. cc2530i2c可同时接受两个传感器的数据吗_汽车方向及维修_玉树沃尔沃S40方向机,宝马531电子方向机进水可以维修吗...
  10. sigprocmask 阻塞进程