codeforces 519A. A and B and Chess,
1 second
256 megabytes
standard input
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.
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.
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.
...QK...
........
........
........
........
........
........
...rk...
White
rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
Draw
rppppppr
...k....
........
........
........
........
K...Q...
........
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.
一个简单的计数比较,坑点在于 the knight — as 'N'.
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cctype>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#define LL long long
#define PF(x) ((x)*(x))
#define LF(x) ((x)*PF(x)) using namespace std;
const int INF=<<-;
const int max9=1e9;
const int max6=1e6;
const int max3=1e3; int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
}
char str[][];
int main()
{
int a,b;
while(cin >> str[])
{
int a=;
int b=;
for(int i=;i<;i++)
cin >> str[i];
for(int i=;i<;i++)
for(int j=;j<;j++)
{
if(str[i][j]=='Q') a+=;
if(str[i][j]=='q') b+=;
if(str[i][j]=='R') a+=;
if(str[i][j]=='r') b+=;
if(str[i][j]=='B') a+=;
if(str[i][j]=='b') b+=;
if(str[i][j]=='N') a+=;
if(str[i][j]=='n') b+=;
if(str[i][j]=='P') a+=;
if(str[i][j]=='p') b+=; }
if(a>b) cout << "White" << endl;
else if(a==b) cout << "Draw" << endl;
else cout << "Black" << endl;
}
return ;
}
codeforces 519A. A and B and Chess,的更多相关文章
- codeforces(559C)--C. Gerald and Giant Chess(组合数学)
C. Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- 排列组合lucas模板
//codeforces 559C|51nod1486 Gerald and Giant Chess(组合数学+逆元) #include <bits/stdc++.h> using nam ...
- Codeforces Round #379 (Div. 2) D. Anton and Chess 水题
D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...
- dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess
Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...
- Codeforces Round #379 (Div. 2) D. Anton and Chess 模拟
题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmem ...
- CodeForces 259A Little Elephant and Chess
Little Elephant and Chess Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- Codeforces 1089E - Easy Chess - [DFS+特判][2018-2019 ICPC, NEERC, Northern Eurasia Finals Problem E]
题目链接:https://codeforces.com/contest/1089/problem/E Elma is learning chess figures. She learned that ...
- Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess DP
C. Gerald and Giant Chess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces Beta Round #7 A. Kalevitch and Chess 水题
A. Kalevitch and Chess 题目连接: http://www.codeforces.com/contest/7/problem/A Description A famous Berl ...
随机推荐
- POJ 1564 Sum It Up(DFS)
Sum It Up Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit St ...
- JS中的的Url传递中文参数乱码,如何获取Url中参数问题
一:Js的Url中传递中文参数乱码问题,重点:encodeURI编码,decodeURI解码: 1.传参页面Javascript代码:<script type=”text/javascript” ...
- bochs 2.6安装和使用
1.安装 Ubuntu 10.04下编译安装Bochs 2.6及问题解决 安装 https://chaoyang.blog.ustc.edu.cn/index.php/archives/124 安装具 ...
- (?m) 标记
<pre name="code" class="html">在和 codec/multiline 搭配使用的时候,需要注意一个问题,grok 正则和 ...
- VS2008生成的程序无法在其它电脑上运行,提示系统无法执行指定的程序
经过一番查找,最给力的参考是 http://www.cnblogs.com/visoeclipse/archive/2010/02/27/1674866.html ------------------ ...
- PCRE的安装及使用
摘自http://www.cnblogs.com/renhao/archive/2011/08/17/2143264.html PCRE的安装及使用 1.主页地址:http://www.pcre.or ...
- ubuntu下的Samba配置:使每个用户可以用自己的用户名和密码登录自己的home目录
http://blog.csdn.net/fly_qj/article/details/21744797 1.先要安装Samba sudo apt-get install samba openssh- ...
- Spring的AOP1
引用:http://my.oschina.net/huangyong/blog/161338 是一个周末,刚给宝宝喂完牛奶,终于让她睡着了.所以现在我才能腾出手来,坐在电脑面前给大家写这篇文章. 今天 ...
- iOS学习之iOS沙盒(sandbox)机制和文件操作(一)
1.iOS沙盒机制 iOS应用程序仅仅能在为该改程序创建的文件系统中读取文件,不能够去其他地方訪问,此区域被成为沙盒,所以全部的非代码文件都要保存在此,比如图像,图标,声音,映像,属性列表,文本文件等 ...
- Unity NGUI 血条制作
NGUI 血条制作步骤 实现过程: 模拟血条的变化当点击按钮Button是血条会实时发生变化. 1.向Unity中导入NGUI2.6.3.unitypackage 点击create your ui 后 ...