[Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves
试题描述
The 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 dis 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).
输入
输出
输入示例
e4
输出示例
数据规模及约定
无
题解
分支结构。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <set>
using namespace std; const int BufferSize = 1 << 16;
char buffer[BufferSize], *Head, *Tail;
inline char Getchar() {
if(Head == Tail) {
int l = fread(buffer, 1, BufferSize, stdin);
Tail = (Head = buffer) + l;
}
return *Head++;
}
int read() {
int x = 0, f = 1; char c = getchar();
while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
return x * f;
} char s[10]; int main() {
scanf("%s", s); if((s[0] == 'a' || s[0] == 'h') && (s[1] == '1' || s[1] == '8')) return puts("3"), 0;
if((s[0] == 'a' || s[0] == 'h') || (s[1] == '1' || s[1] == '8')) return puts("5"), 0;
puts("8"); return 0;
}
[Educational Codeforces Round 16]A. King Moves的更多相关文章
- [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 water.= =. #include <cstdio> ,,,,,-,-,-}; ,-,,,-,,,-,}; #define judge(x,y) x > ...
- Educational Codeforces Round 16 A
Description he only king stands on the standard chess board. You are given his position in format &q ...
- 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 ...
随机推荐
- IOS判断app在appstore是否有可用的更新
iTunes可以提供app的版本信息,主要通过appid获取,如 http://itunes.apple.com/lookup?id=946449501,使用时只需要到iTunes查找自己的appid ...
- Python: Lambda Functions
1. 作用 快速创建匿名单行最小函数,对数据进行简单处理, 常常与 map(), reduce(), filter() 联合使用. 2. 与一般函数的不同 >>> def f (x) ...
- [AaronYang]C#人爱学不学[4]
本文章不适合入门,只适合有一定基础的人看.我更相信知识细节见高低,我是从4.0开始学的,终于有时间系统的学习C#5.0,是5.0中的知识,会特殊标记下.但写的内容也可能含有其他版本framework的 ...
- 【Moqui业务逻辑翻译系列】Shipment Receiver Receives Shipment with Packing Slip but no PO
Shipment Receiver receives shipment. It has invoice tucked into it. Receiver records vendor name, ve ...
- ansible-3 主机清单hosts的设置
主机清单的设置参考:http://www.ansible.com.cn/docs/intro_inventory.html [ceshi]192.168.220.98log ansible_ssh_h ...
- codevs 1690 开关灯 线段树水题
没什么好说的,标记put表示开关是否开着. #include<cstdio> #include<cstring> #include<algorithm> using ...
- POJ 2449Remmarguts' Date K短路模板 SPFA+A*
K短路模板,A*+SPFA求K短路.A*中h的求法为在反图中做SPFA,求出到T点的最短路,极为估价函数h(这里不再是估价,而是准确值),然后跑A*,从S点开始(此时为最短路),然后把与S点能达到的点 ...
- Html-input文本框只能输入数字
onKeyPress="if ((event.keyCode < 48 || event.keyCode > 57)) event.returnValue = false;&qu ...
- 【bzoj1037】 ZJOI2008—生日聚会Party
http://www.lydsy.com/JudgeOnline/problem.php?id=1037 (题目链接) 题意 有n个boy和m个girl排成一排,求使得任意一段的boy个数girl个数 ...
- POJ1065 Area
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18499 Accepted: 5094 Description You ...