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): 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 (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
Source
2016 ACM/ICPC Asia Regional Qingdao Online
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5882
分析:
大体题意:
石头剪刀布这个游戏是公平的,每个手势攻防都是一样的!,现在给你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("Balancedn");
15 else printf("Badn");
16 }
17 }
18 return 0;
19 }
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 什么?一个核同时执行两个线程?
- 如何下载网页上的视频?
- c++ int,unsigned int混合表达式类型转换
- MySQL5.7+查看Waiting for table metadata lock 锁情况
- input如何快速进行规则校验
- 史上最详细的sqlServer手工注入详解
- Spring 基于 Java 的配置
- Spring中的Spring JSR-250 注释之@Resource
- python 用opencv接口把视频逐帧转化为图片
- Element el-tree树形控件的数据处理方法
- 基于docker快速搭建hive环境
- flag区分大小写的sql盲注
- Spring中的Spring JSR-250 注释
- WebRTC 入门指南
- 【DB笔试面试844】在Oracle中,tnsnames.ora文件的作用是什么?