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. How to Pronounce BEAUTIFUL

    How to Pronounce BEAUTIFUL Share Tweet Share Tagged With: 3-Syllable Can you say this word beautiful ...

  2. 趣味编程:CPS风格代码(Java 8,Functional Java版)

    CPS风格代码(Java 8版) package fp; import java.util.function.IntConsumer; public class CPS { static int ad ...

  3. Rxjs 修改Observable 里的值

    有这么一个对象c$: Observable<any> 修改里边的值: 声明一个subject subject: Subject<any>; 在ngOnInit()中进行初始化 ...

  4. 通过IP地址进行精准定位

    可能会遇到这样的问题,服务器或者系统经常被扫描,通过IP地址我们只能查到某一个市级城市,如下图: 当我们想具体到街道甚至门牌号,该怎么办??? 偶然间发现百度地图有高精度IP定位API的接口,通过该接 ...

  5. Delphi声明Record变量后直接初始化

    TARec = record    A1: string;    A2: string;  end; TBRec = record    A1: string;    A2: string;    A ...

  6. RecycleView实现侧滑删除item

    对于列表空间的侧滑操作,网上有很多开源的空间可以使用,Google在它的新控件RecycleView中增加了侧滑的API,完全遵循Material Design设计规范,下面看看效果演示: 下面看看介 ...

  7. chrome input去除黄色背景色

    input:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px white inset; border: 1px solid #CCC!impo ...

  8. MyBatis多对多查询

    -------------------siwuxie095                                 MyBatis 多对多查询         以订单和商品为例,即 一个订单可 ...

  9. HashMap的hash冲突解决方案

    Hash函数 非哈希表的特点:关键字在表中的位置和它之间不存在一个确定的关系,查找的过程为给定值一次和各个关键字进行比较,查找的效率取决于和给定值进行比较的次数. 哈希表的特点:关键字在表中位置和它之 ...

  10. C# 类初始化顺序

    C#的类初始化顺序和Java以及C++类初始化顺序是不同的,曾经我被这个问题害惨了.对于C#和Java,其共同点都是先变量后构造函数,先静态后普通 区别在于,C#是子类变量->父类变量-> ...