zoukankan      html  css  js  c++  java
  • HDU 5882 Balanced Game

    Balanced Game

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


    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
     
     
     
    解析:维持平衡,即每种策略的胜率均为50%。而每种手势对其他手势不是必胜就是必败,要维持平衡,显然手势的种数必须是奇数;否则不能平衡。当手势种数为奇数时,很容易构造出平衡的情况。因此,当手势种数为奇数可以平衡,为偶数时不能平衡。
     
     
     
    #include <cstdio>
    
    int main()
    {
        int t, n;
        scanf("%d", &t);
        while(t--){
            scanf("%d", &n);
            printf(n&1 ? "Balanced
    " : "Bad
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    小记:xml画一个爱心。
    类似UC天气下拉和微信下拉眼睛头部弹入淡出UI交互效果(开源项目)。
    FloatingActionButton增强版,一个按钮跳出多个按钮--第三方开源--FloatingActionButton
    回调机制的实现。
    小记:使用SharedPreferences存储来设置程序第一次进入欢迎界面,以后不会再进入欢迎界面。
    小记:获取系统时间的long值,格式化成可读时间。
    写程序的欢迎界面(运用画图方法画圆球)。
    并发的HashMap为什么会引起死循环?
    zuul重试配置
    zuul超时问题
  • 原文地址:https://www.cnblogs.com/inmoonlight/p/5897455.html
Copyright © 2011-2022 走看看