HDU 5882 Balanced Game

简介: Balanced Game Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 508    Accepted Submission(s): ...

Balanced Game

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 508    Accepted Submission(s): 428


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 (2N1000), 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
分析:

大体题意:

石头剪刀布这个游戏是公平的,每个手势攻防都是一样的!,现在给你n 个手势判断能否公平!

思路:

其实读完题目 猜到了,,没敢立马写= =

思路很简单,要想每一个手势攻防都一样,那么必须n-1个手势有一半攻击自己,有一半防守自己,那么显然n-1是偶数,

当n 是奇数是成立的,否则不成立!

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     int m;
 7     int i,j;
 8     while(scanf("%d",&n)!=EOF)
 9     {
10         while(n--)
11         {
12             scanf("%d",&m);
13             if(m%2==1)
14             printf("Balanced\n");
15             else printf("Bad\n");
16         }
17     }
18     return 0;
19 }

 

目录
打赏
0
0
0
0
34
分享
相关文章
hdu 3750 Guess Game
点击打开链接 题目意思:  给定一个数n,假设有一个m ( 1
799 0
hdu 1546 Idiomatic Phrases Game
点击打开链接hdu 1546 思路:最短路+SPFA 分析: 1  只要建好图,然后利用SPFA求解最短路即可。注意字符串的处理 2  定义一个char ch[10]数组,如果给数组的每一个元素值赋值后,还要记得要在最后ch[9]添加‘\0’,表示结束。
811 0
hdu 3744 A Runing Game
点击打开链接 题目意思:  有n个人在比m米的比赛,现在给出这n个人的当前位置,(起点为0,0-399),以及这n个人的排名,问我么给出的排列是否正确 解题思路:    我们知道对于第一名来说他跑的总的距离是比第二名多的,第二名比第三,依次.......                      首先我么应该先对这n个人的排名进行排序,使得它们从小到大(第一名.....最后一名)。
1095 0
hdu 4647 Another Graph Game
点击打开hdu 4647 思路: 贪心 1 若没有边权,则对点权从大到小排序即可 2 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可。
748 0
HDU 2438 Turn the corner(三分查找)
托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! Turn the corner Time Limit: 3000/1000 MS (Java/O...
977 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等