2016 ACM/ICPC 青岛区域赛网络赛 1005 Balanced Game (找规律)
来源:互联网 发布:如何获取网站数据库 编辑:程序博客网 时间:2024/05/17 03:48
Balanced Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2126 Accepted Submission(s): 1448
Total Submission(s): 2126 Accepted Submission(s): 1448
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 exactly50% no matter how the other one plays (if there is a tie, repeat this game until someone wins). Given an integerN , representing the count of shapes in a game. You need to find out if there exist a rule to make this game balanced.
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
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 integerN (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.
For each test case, there is only one line with an integer
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
3235
Sample Output
BadBalancedBalanced题意: 给出n个手势,判断是否能否达到平衡,比如n=3(剪子、包袱、锤),可以达到平衡,再比如题目中给出的n=5,也能够达到平衡,,,思路: 一开始读错题,看成了N个人,首先想到找规律,发现N=3、4、5时可以,n=6的时候可以看做两个3,之后的都可以,于是只判断n是否大于2,,结果秒错。。 最后想到,平衡状态应该是每个手势克与被克的次数是一样的,即总次数是偶数,如果n个手势都要出现,那么每个手势与其他n-1个手势都应该有克与被克的关系,就像题目中的n=5一样,每个手势与其他4个都有克与被克的关系,就可以设置一种规则,让每个手势赢2次,输2次,无论怎么出,只要5个手势都出现,一定是平衡,, 如果n=6,那么每个手势与其他5个手势都有关系,无论怎么设置规则,至少有一个手势不会平衡,, 想到这里就会发现,如果n是偶数,n-1为奇数,不能达到平衡,,反之可以。。以下AC代码:#include<stdio.h>int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); if(n%2) printf("Balanced\n"); else printf("Bad\n"); } return 0;}
0 0
- 2016 ACM/ICPC 青岛区域赛网络赛 1005 Balanced Game (找规律)
- hdu 5882 Balanced Game 2016ACM/ICPC青岛赛区网络赛1005
- 2016 ACM/ICPC 青岛区域赛网络赛 1001 I Count Two Three(打表+二分)
- 2017ACM-ICPC亚洲区域赛(青岛站)
- HDU5876 补图求最短路 2016ACM ICPC青岛网络赛
- 2016 ACM/ICPC Asia Regional Qingdao Online(青岛网络赛)
- 2016 ACM/ICPC 青岛赛区网络赛 XM Reserves
- 青岛网赛1005 HDU5882 Balanced Game
- 2016 ICPC 青岛网络赛 1005
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 C.Sum(找规律)
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 E.Maximum Flow(找规律?)
- 计蒜客17116 Sum 找规律 2017 ACM-ICPC 亚洲区(西安赛区)网络赛
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 C.Sum(找规律)
- 2016 ICPC 青岛 网络赛
- HDU 5882 Balanced Game(2016亚洲区青岛站网络赛)
- 2017 ACM/ICPC 亚洲区域赛 青岛赛区
- ACM-ICPC亚洲区域赛青岛站总结
- 2016 acm/icpc 青岛网络赛 题解(hdu 5878-5889,9道题)
- MySQL的用户变量和系统变量
- Web服务器(Nginx、php)+图片服务器
- 自定义ViewGroup学习
- GCC编程四个过程:预处理-编译-汇编-链接
- linux umount 时出现device is busy 的处理方法--fuser
- 2016 ACM/ICPC 青岛区域赛网络赛 1005 Balanced Game (找规律)
- java多线程之对象的并发访问
- 例题:大理石在哪儿(UVa 10474)
- Caffe: Data layer prefetch queue empty
- GCC中使用预编译头文件
- StoryBoard中默认勾选Adjust Scroll View Insets选项,导致导航条下方的控件看不到
- TableLayout指示器修改标签字体
- 网络TCP建立连接为什么需要三次握手而结束要四次
- hdu5890 bitset 优化dp