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

    A. A and B and Chess
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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

    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.

    题意:给你一个棋盘,每一个棋子有一个分数,大写是属于白色方,小写是属于黑色方,然后问你哪个分数高

    题解:扫一遍就好,然后唯一的坑点就是Knight的代表是N,而不是K

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 100001
    #define eps 1e-9
    const int inf=0x7fffffff;   //无限大
    int sum1=0;
    int sum2=0;
    void deal(string s)
    {
            int sum=0;
            for(int i=0;i<s.size();i++)
            {
                    if(s[i]=='Q')
                            sum1+=9;
                    else if(s[i]=='R')
                            sum1+=5;
                    else if(s[i]=='B')
                            sum1+=3;
                    else if(s[i]=='N')
                            sum1+=3;
                    else if(s[i]=='P')
                            sum1+=1;
                    else if(s[i]=='q')
                            sum2+=9;
                    else if(s[i]=='r')
                            sum2+=5;
                    else if(s[i]=='b')
                            sum2+=3;
                    else if(s[i]=='n')
                            sum2+=3;
                    else if(s[i]=='p')
                            sum2+=1;
            }
            //return sum;
    }
    int main()
    {
            string s;
            for(int i=0;i<8;i++)
            {
                    cin>>s;
                    deal(s);
            }
            if(sum1>sum2)
                    cout<<"White"<<endl;
            else if(sum2>sum1)
                    cout<<"Black"<<endl;
            else
                    cout<<"Draw"<<endl;
            return 0;
    
    }
  • 相关阅读:
    LINQ学习笔记 Join 与 Group join
    JAVA如何解压缩ZIP文档
    Thread.getContextClassLoader() is null
    如何部署 sources and javadoc jars
    Maven部署异常:on project standalone-pom: Cannot deploy artifact from the local repository解决方法
    Git忽略规则及.gitignore规则不生效的解决办法
    Java算法HmacSHA256不可用
    DHCP协议
    【Redis】Redis实现计数器
    【前端】JavaScript原型链与继承
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4308470.html
Copyright © 2011-2022 走看看