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 ...
随机推荐
- 2013年9月份阿里JAVA面试经历
面试时间:2013-9 面试地点:合工大 面试内容: 1. struts2怎么实现的,原理是什么 2. session是怎么实现的?存储在哪里? 3. Java怎么创建链表的? 定义一个结点类,再定义 ...
- Roads in Berland(图论)
Description There are n cities numbered from 1 to n in Berland. Some of them are connected by two-wa ...
- Keil C -WARNING L15: MULTIPLE CALL TO SEGMENT
1.第一种错误信息 ***WARNING L15: MULTIPLE CALL TO SEGMENT SEGMENT: ?PR?_WRITE_GMVLX1_REG?D_GMVLX1 CALLER1: ...
- 正则取页面图片URL和TABLE BackGround
/// <summary> /// 根据html文本返回url地址集合 /// </summary> /// <param name="sHtmlText&qu ...
- linux下vi命令大全(转载)
进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于最后 ...
- Han Move(细节题)
Problem 1609 - Han Move Time Limit: 1000MS Memory Limit: 65536KB Total Submit: 620 Accepted: 1 ...
- 高效CSS書寫規範及CSS兼容性
一.選擇器針對性說明 某一元素的多个规则集中,选择器的针对性越高,该规则集的权重也就越高.针对性相同的,后出现的规则集的权重更高. * {} /* a=0 b=0 c=0 d=0 -> spec ...
- Python 练习 —— 2048
1. 引言 2048 这段时间火的不行啊,大家都纷纷仿造,"百家争鸣",于是出现了各种技术版本号:除了手机版本号,还有C语言版.Qt版.Web版.java版.C#版等,刚好我接触P ...
- Exploring TCP state machine by graphs
States TCP includes 11 states, they are: LISTEN SYN_SENT SYN_RECV ESTABLISHED FIN_WAIT1 CLOSE_WAIT F ...
- minicom与USB转串口
实验器材:mini6410 连接方式:ARM板通过USB转串口线连接到pc机 下面是具体的设置了. 默认情况下,UBUNTU安装了USB转串口驱动(pl2303). 1.# lsmod | grep ...