Codeforces Round #294 (Div. 2)A - 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.
题意:给你一个棋盘,每一个棋子有一个分数,大写是属于白色方,小写是属于黑色方,然后问你哪个分数高
题解:扫一遍就好,然后唯一的坑点就是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=;
int sum2=;
void deal(string s)
{
int sum=;
for(int i=;i<s.size();i++)
{
if(s[i]=='Q')
sum1+=;
else if(s[i]=='R')
sum1+=;
else if(s[i]=='B')
sum1+=;
else if(s[i]=='N')
sum1+=;
else if(s[i]=='P')
sum1+=;
else if(s[i]=='q')
sum2+=;
else if(s[i]=='r')
sum2+=;
else if(s[i]=='b')
sum2+=;
else if(s[i]=='n')
sum2+=;
else if(s[i]=='p')
sum2+=;
}
//return sum;
}
int main()
{
string s;
for(int i=;i<;i++)
{
cin>>s;
deal(s);
}
if(sum1>sum2)
cout<<"White"<<endl;
else if(sum2>sum1)
cout<<"Black"<<endl;
else
cout<<"Draw"<<endl;
return ; }
Codeforces Round #294 (Div. 2)A - A and B and Chess 水题的更多相关文章
- Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题
A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...
- Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题
A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...
- Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题
A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...
- Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题
A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...
- Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo 水题
B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...
- Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
随机推荐
- C# 调用WSDL接口及方法
1.首先需要清楚WSDL的引用地址 如:http://XX.XX.4.146:8089/axis/services/getfileno?wsdl 上述地址的构造为 类名getfileno. 2.在.N ...
- 14 Go's Declaration Syntax go语言声明语法
Go's Declaration Syntax go语言声明语法 7 July 2010 Introduction Newcomers to Go wonder why the declaration ...
- docker使用Dockerfile构建ssh容器
一.使用Dockerfile构建centos 1.创建 Dockerfile mkdir centos # 创建一个目录存放之后的Dockerfile,目录名无所谓 cd centos # 进入目录 ...
- Java基础83 JSP标签及jsp自定义标签(网页知识)
1.JSP标签 替代jsp脚本,用于jsp中执行java代码1.1.内置标签: <jsp:forward></jsp:forward> 相当于:request.getReu ...
- tomcat数据源配置DBCP
原文件: https://www.cnblogs.com/sicd/p/4053780.html DBCP object created 日期 by the following code was ne ...
- eclipse导入/导出项目要注意三个地方
这个三个地方的jdk必须保持一致,不报错
- css3在动画完成后执行事件
第一种方法: 用计时器,设定一个和动画时长一样的time,过time事件去执行这个函数. setTimeout(function(){ },time); 第二种方法: 当-webkit-animati ...
- wpf mvvm模式下的image绑定
view文件 <Image Grid.Column="2" Width="48" Height="64" Stretch=" ...
- HDU 1068 Girls and Boys(最大独立集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 题目大意:有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人都互相不认识,求该集合 ...
- SCTP客户端与服务器
/** * @brief - Send a message, using advanced SCTP features * The sctp_sendmsg() function allows you ...