博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF A and B and Chess
阅读量:6831 次
发布时间:2019-06-26

本文共 3071 字,大约阅读时间需要 10 分钟。

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 水题。。。MAP第一发
1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 using namespace std;10 11 const int SIZE = 10;12 char MAP[SIZE][SIZE];13 int main(void)14 {15 map
white;16 map
black;17 white['Q'] = 9;18 white['R'] = 5;19 white['B'] = 3;20 white['N'] = 3;21 white['P'] = 1;22 white['K'] = 0;23 24 black['q'] = 9;25 black['r'] = 5;26 black['b'] = 3;27 black['n'] = 3;28 black['p'] = 1;29 white['k'] = 0;30 31 int sum_w,sum_b;32 char ch;33 sum_w = sum_b = 0;34 for(int i = 0;i < 8;i ++)35 for(int j = 0;j < 8;j ++)36 {37 scanf(" %c",&ch);38 if(islower(ch))39 sum_b += black[ch];40 else if(isupper(ch))41 sum_w += white[ch];42 }43 if(sum_w > sum_b)44 puts("White");45 else if(sum_w < sum_b)46 puts("Black");47 else48 puts("Draw");49 50 return 0;51 }

 

转载于:https://www.cnblogs.com/xz816111/p/4412346.html

你可能感兴趣的文章
linux命令学习-复制(cp,scp)
查看>>
cocos2d-x开发记录:二,基本概念(粒子系统,Scheduler和定时器)
查看>>
去掉Flex4生成的SWF加载时的进度条
查看>>
如何使用 MasterPage
查看>>
load dll
查看>>
Linux给指定用户或全部用户(已登录)发送消息
查看>>
C语言 队列 链式结构 实现
查看>>
关于同一用户不能同时登录问题的探讨(1/2)
查看>>
android-support-v7-appcompat的配置使用
查看>>
LINUX的STRACE命令用法 [转]
查看>>
[4] 圆锥(Cone)图形的生成算法
查看>>
[16] 螺旋面(Spire)图形的生成算法
查看>>
Linux内存管理之bootmem分配器
查看>>
谈谈Flash图表中数据的采集
查看>>
C语言字符串匹配函数
查看>>
【c++】explicit 隐式类类型转换
查看>>
Android中GridView使用总结
查看>>
Win Socket编程原理及简单实例
查看>>
使IIS Express支持其他网络客户端访问
查看>>
Shell:sed流编辑器
查看>>