codeforces 710A King Moves(水)

output

standard output

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

King moves from the position e4

Input

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‘.

Output

Print the only integer x — the number of moves permitted for the king.

Example

input

e4

output

8

分析:给你横纵坐标,瞎搞就好。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     char str[3];
 6     ios::sync_with_stdio(false);
 7     cin.tie(0);
 8     cin >> str;
 9     if(str[0] == ‘a‘)
10     {
11         if(str[1] == ‘8‘ || str[1] == ‘1‘)
12         cout << 3 << endl;
13         else
14         cout << 5 << endl;
15     }
16     else if(str[0] == ‘h‘)
17     {
18         if(str[1] == ‘8‘ || str[1] == ‘1‘)
19         cout << 3 << endl;
20         else
21             cout << 5 << endl;
22     }
23     else if(str[1] == ‘8‘ || str[1] == ‘1‘)
24     {
25         cout << 5 << endl;
26     }
27     else
28         cout << 8 << endl;
29     return 0;
30 }
时间: 2024-10-15 10:32:06

codeforces 710A King Moves(水)的相关文章

CodeForces 710A King Moves (水题)

题意:给定一个坐标,问你皇后有几个方向可以走. 析:直接格举那八个方向即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring&g

【模拟】Codeforces 710A King Moves

题目链接: http://codeforces.com/problemset/problem/710/A 题目大意: 国际象棋标准8X8棋盘,国王能往周围8个方向走.输入国王的位置,输出当前国王能往几个方向走. 题目思路: [模拟] 签到题(看错题目WA了一次).边界处理下就好. 1 // 2 //by coolxxx 3 //#include<bits/stdc++.h> 4 #include<iostream> 5 #include<algorithm> 6 #in

codeforces 710A A. King Moves(水题)

题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include &l

CodeForce 710A King Moves

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 d is the row from '1' to '8'. Find the number of moves permitted for the king. Check the king's mov

CodeForces 22D Segments 排序水题

题目链接:点击打开链接 右端点升序,取右端点 暴力删边 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10

Codeforces 30D King&#39;s Problem? 模拟

首先将n个点排序,找出排序后的K,然后分情况讨论. 当 k == n+1时,显然是 k->1->n || k->n->1这两种的较小值,因为三角形的两边之和大于第三边. 当1 <= k && k <= n 时: 1 , k -> 1 -> n+1 -> k+1 ->n  ||  k -> n -> n+1 -> k-1 -> 1,当k+1 || k-1 不存在时将对应步骤忽略. 2 , k - > 1

codeforces 589 I - Lottery(水)

I - Lottery Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 589I Description Today Berland holds a lottery with a prize — a huge sum of money! There are k persons, who attend the lottery

CodeForces 706C Hard problem (水DP)

题意:对于给定的n个字符串,可以花费a[i]  将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][maxn],d[0][i]表示第 i 个不反转是最小花费,d[1][i]表示第 i 个反转最小花费,那么剩下的就很简单了么, 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio>

codeforces 706A A. Beru-taxi(水题)

题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> using n