Educational Codeforces Round 16 A
Description
he only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).
King moves from the position e4
The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.
Print the only integer x — the number of moves permitted for the king.
e4
8
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if(s[0]=='a'&&s[1]=='8')
{
cout<<"3"<<endl;
return 0;
}
else if(s[0]=='h'&&s[1]=='8')
{
cout<<"3"<<endl;
return 0;
}
else if(s[0]=='a'&&s[1]=='1')
{
cout<<"3"<<endl;
return 0;
}
else if(s[0]=='h'&&s[1]=='1')
{
cout<<"3"<<endl;
return 0;
}
else if(s[0]=='a'&&(s[1]>='1'&&s[1]<='7'))
{
cout<<"5"<<endl;
return 0;
}
else if(s[0]=='h'&&(s[1]>='1'&&s[1]<='7'))
{
cout<<"5"<<endl;
return 0;
}
else if((s[0]>='b'&&s[0]<='g')&&(s[1]=='8'))
{
cout<<"5"<<endl;
return 0;
}
else if((s[0]>='b'&&s[0]<='g')&&(s[1]=='1'))
{
cout<<"5"<<endl;
return 0;
}
else
{
cout<<"8"<<endl;
}
return 0;
}
Educational Codeforces Round 16 A的更多相关文章
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 16 E. Generate a String dp
题目链接: http://codeforces.com/problemset/problem/710/E E. Generate a String time limit per test 2 seco ...
- Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)
Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...
- Educational Codeforces Round 16 E. Generate a String (DP)
Generate a String 题目链接: http://codeforces.com/contest/710/problem/E Description zscoder wants to gen ...
- Educational Codeforces Round 16
A. King Moves water.= =. #include <cstdio> ,,,,,-,-,-}; ,-,,,-,,,-,}; #define judge(x,y) x > ...
- Educational Codeforces Round 16 A B C E
做题太久也有点累了..难题不愿做 水题不愿敲..床上一躺一下午..离下一场div2还有点时间 正好有edu的不计分场 就做了一下玩玩了 D是个数学题 F是个AC自动机 都没看明白 留待以后补 A 给出 ...
随机推荐
- sdutoj 2152 Balloons
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2152 Balloons Time Limit: ...
- Demo13
this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void o ...
- ActivityGroup中EditText无法删除的问题
坑,以前比较少用ActivityGroup,最近使用才发现ActivityGroup中多个Activity中如果都有Edittext是无法后退删除. 网上说有种方法监听dispatchKeyEvent ...
- css 标签 垂直居中
<!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> < ...
- Delphi的DateToStr StrToDate格式灵活用法
Delphi的DateToStr StrToDate格式灵活用法 2008-04-09 10:19 procedure TForm1.Button1Click(Sender: TObject);var ...
- linux配置java环境变量(详细)【转】
转自:http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux ...
- Maven3.x 插件开发入门
Maven工具有很多插件,各种各样的插件,让我们开发调试过程中非常方便,但是终究是有你想要的但是现目前插件不能满足的(可能性非常非常低),这个时候就需要使用其他的替代工具,或者是自己来开发一个Mave ...
- jenkins+jmeter+ant搭建接口测试平台
接口测试的重点是检查数据的交换,传递和控制管理过程以及系统间的相互逻辑依赖关系. 接口测试的流程 项目启动后,测试人员要尽早拿到接口测试文档. 开始编写接口测试用例 将接口测试用例部署到持续集成的测试 ...
- C#:WPF绘制问题
1.问题描述:切换画笔后,鼠标呈现画笔,但绘制界面需要点击后才能绘制,体验比较差 注:如果将切换为画笔或橡皮擦的功能放在二级菜单中则无次问题 解决方法(大体如此): 1)在第三方中,先创建完绘制画面和 ...
- WMsg参数常量值
//WMsg参数常量值: //创建一个窗口 const int WM_CREATE = 0x01; //当一个窗口被破坏时发送 const int WM_DESTROY = 0x02; //移动一个窗 ...