Balanced Game

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 297    Accepted Submission(s): 265

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
 

题意是给n个点,问这n个点能不能组成平衡的游戏,题目说的很多,说白了就是n个点之间两两建边,能否保证每个点入度与出度相等

我们容易知道偶数个点有奇数条边与他相连,奇数个点有偶数条边与他相连,所以分奇偶判断即可

#include<cstdio>
int main()
{
int o,n;
while(~scanf("%d",&o))
{
while(o--)
{
scanf("%d",&n);
if(n%2)
printf("Balanced\n");
else
printf("Bad\n");
}
}
return 0;
}


hdu 5882 Balanced Game 2016-09-21 21:22 80人阅读 评论(0) 收藏的更多相关文章

  1. iOS 消息推送原理及实现总结 分类: ios技术 2015-03-01 09:22 70人阅读 评论(0) 收藏

    在实现消息推送之前先提及几个于推送相关概念,如下图: 1. Provider:就是为指定IOS设备应用程序提供Push的服务器,(如果IOS设备的应用程序是客户端的话,那么Provider可以理解为服 ...

  2. *** glibc detected *** malloc(): memory corruption 分类: C/C++ Linux 2015-05-14 09:22 37人阅读 评论(0) 收藏

    *** glibc detected *** malloc(): memory corruption: 0x09eab988 *** 发现是由于memset越界写引起的. 在Linux Server上 ...

  3. sscanf 函数 分类: POJ 2015-08-04 09:19 4人阅读 评论(0) 收藏

    sscanf 其实很强大 分类: 纯C技术 技术笔记 2010-03-05 16:00 12133人阅读 评论(4) 收藏 举报 正则表达式stringbuffercurlgoogle 最近在做日志分 ...

  4. 排序练习——找出前m大的数字 分类: 排序 2015-06-08 09:33 21人阅读 评论(0) 收藏

    排序练习--找出前m大的数字 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 给定n个数字,找出前m大的数字.   输入  多组输 ...

  5. windows server 2008 R2域中的DC部署 分类: AD域 Windows服务 2015-06-06 21:09 68人阅读 评论(0) 收藏

    整个晚上脑子都有点呆滞,想起申请注册好的博客还从来都不曾打理,上来添添生机.从哪里讲起呢,去年有那么一段时间整个人就陷在域里拔不出来,于是整理了一些文档,害怕自己糊里糊涂的脑子将这些东西会在一觉醒来全 ...

  6. hdu 1030 Delta-wave (C++, 0ms, explanatory comments.) 分类: hdoj 2015-06-15 12:21 45人阅读 评论(0) 收藏

    problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include ...

  7. hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏

    errors made, boundary conditions, <= vs < , decreasing vs increasing , ++, –, '0'/'1' vs 0/1 p ...

  8. Hiking 分类: 比赛 HDU 函数 2015-08-09 21:24 3人阅读 评论(0) 收藏

    Hiking Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Subm ...

  9. Encoding 分类: HDU 2015-06-25 21:56 9人阅读 评论(0) 收藏

    Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

随机推荐

  1. Spring,Hibernate 集成解决多hbm.xml文件繁多的方案

    开发一个大一点的项目有很多的hbm.xml文件,有时候上百个也不稀奇,如果用 <property name="mappingLocations"> <list&g ...

  2. godaddy nginx https 配置

    一. 生成秘钥key,运行: $ openssl genrsa -des3 -out server.key 2048 1 会有两次要求输入密码,输入同一个即可 输入密码 然后你就获得了一个server ...

  3. Java Tomcat下载、安装和环境变量配置

    win10下Tomcat的下载.安装和环境变量的配置 -----made by siwuxie095                             1.首先到Tomcat官网,传送阵:点击开 ...

  4. 240. Search a 2D Matrix II&&74. Search a 2D Matrix 都用不严格递增的方法

    一句话思路:从左下角开始找.复杂度是o(m+n). 一刷报错: 应该是一个while循环中有几个条件判断语句,而不是每个条件判断语句里去加while,很麻烦 数组越界了.从0开始,y的最大条件应该是& ...

  5. dddddddddddddddddd

    PacificA: Replication in log-based distributed storage systemshttp://research.microsoft.com:8082/pub ...

  6. samba配置(z)

    http://www.cnblogs.com/mchina/archive/2012/12/18/2816717.html

  7. jquery:为动态加载的元素添加点击事件

    jquery:为动态加载的元素添加点击事件 最近在做项目的时候遇到了这样一个问题,给用ajax动态加载出来的内容添加点击事件,但是怎么都触发不了,经过查询试验总结出正确的写法 在jquery1.7之前 ...

  8. process_创建进程

    import multiprocessingimport time#方式一def worker(interval): n = 5 while n > 0: print("The tim ...

  9. 人类基因组三代组装: cano

    git clone https://github.com/marbl/canu.git cd canu/src make -j <number of threads> 使用实例: canu ...

  10. 2018.09.12 hdu2473Junk-Mail Filter(并查集)

    传送门 一开始开题还以为是平衡树. 仔细想了一想并查集就可以了. 合并操作没什么好说的. 删除操作:对于每个点记录一个pos值表示原来的点i现在的下标是什么. 每次删除点i是就新建一个点cnt,然后令 ...