ACM/ICPC Asia Regional Qingdao Online 1005 Balanced Game

Source: Internet
Author: User

Topic Links:

http://acm.hdu.edu.cn/showproblem.php?pid=5882

problem DescriptionRock-paper-scissors is a zero-sum hand game usually played between both people, in which each player simultaneously forms O NE 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 would beat another player who Had chosen scissors ("Rock crushes scissors") but would lose to one who had played paper ("Paper covers Rock"); A play of paper would lose to a play of scissors ("scissors cut paper"). If Both players choose the same shape, the game is tied and was usually immediately replayed to break the tie.

Recently, there is a upgraded edition of the Game:rock-paper-scissors-spock-lizard, in which there are totally five Shap Es. 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 have, rock crushes scissors.

Both Rock-paper-scissors and Rock-paper-scissors-spock-lizard is balanced games. Because There does not exist a strategy which are better than another. In other words, if one chooses shapes randomly, the possibility he or she wins is exactly No matter how the other one plays (if there are a tie, repeat this game until someone wins). Given an integer N, representing the count of shapes in a game. You need to find if there exist a rule to make this game balanced.

InputThe first line of input contains an integer t, the number of test cases. T test cases follow.
For each test case, there was only one line with an integern (2≤n≤) , as described above.

This is the sample explanation.

In the first case, donate the other shapes as A and B. There was only kind of rules:a defeats B, or b defeats A. Obviously, both situation, one shapes is better than ano Ther. Consequently, this game was not balanced.

In the second case, donate the 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's easy-to-set a rule according to that of Rock-paper-scissors-spock-lizard.

OutputFor each test cases, output ' Balanced ' if there exist a rule to make the game Balanced, otherwise output ' bad '.

Sample Input3235

Sample Outputbadbalancedbalanced Hint:

Test instructions

Ask nnn a gesture of stone scissors cloth game can guarantee that each gesture winning is the same.

Exercises

When each gesture's number of attack and defense is exactly equal to ensure balance, nnn it is easy to draw is odd when the game balance, otherwise unbalanced. Registration questions.

Code:

#include <cstdio>int main () {    int t;    scanf ("%d", &t);    while (t--)    {        int n;        scanf ("%d", &n);        if (n%2==1)            printf ("balanced\n");        else            printf ("bad\n");}    }

  

ACM/ICPC Asia Regional Qingdao Online 1005 Balanced Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.