zoukankan      html  css  js  c++  java
  • Codeforces Round #294 (Div. 2)——A——A and B and Chess

    A and B are preparing themselves for programming contests.

    To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.

    For each chess piece we know its weight:

    • the queen's weight is 9,
    • the rook's weight is 5,
    • the bishop's weight is 3,
    • the knight's weight is 3,
    • the pawn's weight is 1,
    • the king's weight isn't considered in evaluating position.

    The player's weight equals to the sum of weights of all his pieces on the board.

    As A doesn't like counting, he asked you to help him determine which player has the larger position weight.

    Input

    The input contains eight lines, eight characters each — the board's description.

    The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters.

    The white pieces are denoted as follows: the queen is represented is 'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the pawn — as 'P', the king — as 'K'.

    The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively.

    An empty square of the board is marked as '.' (a dot).

    It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on.

    Output

    Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal.

    Sample test(s)
    input
    ...QK...
    ........
    ........
    ........
    ........
    ........
    ........
    ...rk...
    output
    White
    input
    rnbqkbnr
    pppppppp
    ........
    ........
    ........
    ........
    PPPPPPPP
    RNBQKBNR
    output
    Draw
    input
    rppppppr
    ...k....
    ........
    ........
    ........
    ........
    K...Q...
    ........
    output
    Black
    Note

    In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5.

    In the second test sample the weights of the positions of the black and the white pieces are equal to 39.

    In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16.

    大意:统计大写小写分别的和,水~~

    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
        char map[10][10];
        int w,b;
        for(int i = 0; i < 8; i++){
            gets(map[i]);
            getchar;
        }
        w = b = 0;
       for(int i = 0; i < 8; i++){
         for(int j = 0; j < 8; j++){
                switch(map[i][j]){
                case 'q':
                    b += 9; break;
                case 'r' :
                    b += 5; break;
                case 'b':
                    b += 3;break;
                case 'n':
                    b += 3; break;
                case 'p':
                    b += 1;break;
                case 'Q':
                   w += 9;break;
                case 'R':
                    w+=5;break;
                case 'B':
                    w+=3;break;
                case'N':
                    w+=3;break;
                case'P' :
                    w+=1;break;
                }
            }
         }
         if(w > b)
            printf("White
    ");
         else if ( w < b)
            printf("Black
    ");
         else printf("Draw
    ");
      return 0;
    }
    View Code
  • 相关阅读:
    在传统软件公司十年深恶痛绝的感受
    前端 100 问:能搞懂80%的请把简历给我
    中专毕业的他,是如何逆袭为 360 资深程序员?
    别再参加领导力培训课程了,这本领导力提升书籍推荐给你
    企业管理书籍推荐,读完这个系列的书就是上完了整个MBA
    如何做好人才管理?人才管理书籍推荐
    如何管理好员工?你可能需要看看这本人员工管理方面的经典书籍
    领导与管理的区别和异同:什么是领导?什么是管理?
    一名优秀的HR需要具备哪些素质与能力?
    销售书籍推荐:做销售你究竟该看什么书?
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4350036.html
Copyright © 2011-2022 走看看