[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).

输入

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 <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;
}

转载于:https://www.cnblogs.com/xiao-ju-ruo-xjr/p/5806704.html

[Educational Codeforces Round 16]A. King Moves相关推荐

  1. Educational Codeforces Round 16 C. Magic Odd Square 矩阵构造

    传送门 文章目录 题意: 思路: 题意: 给你一个奇数nnn,让你构造一个n∗nn*nn∗n的矩阵,矩阵的每个位置依次填上[1,n∗n]之内的数[1,n*n]之内的数[1,n∗n]之内的数,满足每行. ...

  2. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  3. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  4. Educational Codeforces Round 24 E. Card Game Again(双指针)

    题目链接:Educational Codeforces Round 24 E. Card Game Again 题意: 给你n个数和一个数k. 现在每次可以拿掉前x个数,后y个数,剩下的数的乘积要能被 ...

  5. Educational Codeforces Round 25 G. Tree Queries

    题目链接:Educational Codeforces Round 25 G. Tree Queries 题意: 给你一棵树,一开始所有的点全是黑色,有两种操作. 1 x 将x这个点变为黑色,保证第一 ...

  6. Educational Codeforces Round 116 (Rated for Div. 2) A B C

    Educational Codeforces Round 116 (Rated for Div. 2) A B C A. AB Balance 题意:使得区间内ab的数量的ba的数量相同,每次操作只能 ...

  7. Educational Codeforces Round 105 (Rated for Div. 2) 题解

    Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String 枚举ABC分别为"( "和 " )&q ...

  8. Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces-题解

    目录 Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces Problem Description Input Outp ...

  9. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

最新文章

  1. java构造方法的书写和注意事项(入门可看)
  2. 关于假冒网站仿冒网易云信官网相关情况的声明
  3. debian/deepin 15.3 15.4安装jdk 1.7 (或jdk 7),配置默认环境
  4. vscode 安装包_VS Code的下载与安装(更改插件的安装位置)
  5. 【图像超分辨率】(SPSR)Structure-Preserving SR with Gradient Guidance
  6. 二叉树C++ | 实现删除节点_4
  7. 软件需求与分析课堂讨论
  8. html缓存效果代码,html5缓存(示例代码)
  9. Linux 操作系统镜像下载
  10. sql server 2005 32位+64位、企业版+标准版、CD+DVD 下载地址大全【申明:来源于网络】
  11. c++打印心形_c语言如何打印心
  12. C++中的stack类
  13. STM32LL库使用——SPI通信
  14. 吴军 阅读与写作50讲 02 如何读懂作者的内心 读后感
  15. Digispark ATTINY85 Arduino IDE 开发
  16. python网盘搜索引擎_打造一个蓝奏云网盘搜索引擎
  17. PY32 单片机离线烧录器使用说明
  18. Axon Framework简介
  19. 弘辽科技:淘宝14天降权会恢复吗?多久能恢复正常?
  20. matlab星三角变压器,变压器星三角接法_主变低压侧三角接法

热门文章

  1. 一篇文章让你了解区块链技术的发展阶段
  2. 比特币挖矿——区块链技术
  3. 这就是为什么我们需要在React的类组件中绑定事件处理程序
  4. 需求简报_代码简报:有史以来最怪诞的丑毛衣
  5. 我开发的代码,如何申请版权_代码简介:我花了3个月时间申请开发人员职位。 这是我学到的。...
  6. 如何高效地爬取链家的房源信息(二)
  7. 从变量地址到指针再到指针变量
  8. Java培训完可以应用在什么领域
  9. 通过yum安装配置lamp
  10. 支付宝接口使用文档说明 支付宝异步通知