CodeForces 710A King Moves (水题)
题意:给定一个坐标,问你皇后有几个方向可以走。
析:直接格举那八个方向即可。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 100000000000000000;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5;
const int mod = 1e9 + 7;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
inline LL Max(LL a, LL b){ return a < b ? b : a; }
inline LL Min(LL a, LL b){ return a > b ? b : a; }
inline int Max(int a, int b){ return a < b ? b : a; }
inline int Min(int a, int b){ return a > b ? b : a; }
char s[10]; int main(){
while(scanf("%s", s) == 1){
int x = s[0] - 'a'+1;
int y = s[1] - '0';
int ans = 0;
for(int i = -1; i < 2; ++i){
for(int j = -1; j < 2; ++j){
if(!i && !j) continue;
if(x + i > 0 && x + i <= 8 && y + j > 0 && j + y <= 8) ++ans;
}
}
printf("%d\n", ans);
}
return 0;
}
CodeForces 710A King Moves (水题)的更多相关文章
- codeforces 710A King Moves(水)
output standard output The only king stands on the standard chess board. You are given his position ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- CodeForces 710A King Moves(水题-越界问题)
题目链接:http://codeforces.com/problemset/problem/710/A 题目大意:在一个棋盘中给出一个位置,判断该位置周围8个点还有几个点可以摆放棋子. AC代码解释解 ...
- 【模拟】Codeforces 710A King Moves
题目链接: http://codeforces.com/problemset/problem/710/A 题目大意: 国际象棋标准8X8棋盘,国王能往周围8个方向走.输入国王的位置,输出当前国王能往几 ...
- CodeForces 710A King Moves
简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
随机推荐
- win32窗口机制之CreateWindow
CreateWindow 函数功能:该函数创建一个重叠式窗口.弹出式窗口或子窗口.它指定窗口类,窗口标题,窗口 风格,以及窗口的初始位置及大小(可选的).该函数也指定该窗口的父窗口或所属窗 ...
- hdu 1429 胜利大逃亡(续) (bfs+状态压缩)
又开始刷题了 题意:略过. 分析:主要是确定状态量,除了坐标(x,y)之外,还有一个key状态,就好比手上拿着一串钥匙.状态可以用位运算来表示:key&(x,y)表示判断有没有这扇门的钥匙,k ...
- 《深入浅出嵌入式底层软件开发》—1. ARM汇编编程基础
1.1 ARM CPU寄存器 ARM的汇编编程,本质上就是针对CPU寄存器的编程,所以要搞清楚ARM有哪些寄存器:ARM寄存器分为两类:普通寄存器和状态寄存器:普通寄存器一共有16个,分别为R0——R ...
- php排序测试
对 http://www.cnblogs.com/kudosharry/articles/2521621.html 这个补充的调用系统sort()函数的测试结果 1000个随机数: 直接插入排序:时间 ...
- 【自动化测试】Selenium 下载文件
用curl确定要下载的文件是什么类型的:另一种方法是使用requests 模块来查找内容类型 文件类型 http://tool.oschina.net/commons 1.先设置下载的目录,下载文件的 ...
- 【自动化测试】Selenium 2.0 学习笔记
定位下拉框元素,要记得先把鼠标挪过去再进行定位. 定位元素用的是find_element_by.... python的模块化还要去思考下 unittest框架使用的时候,py文件命名不要用unitte ...
- 关于"user.dir"的认识
最近阅读了一些tomcat源码,看到tomcat在读取jar包外配置文件,是将“user.dir”的路径作为home path文件即 通过System.getProperty("user.d ...
- 一道program test题目
前天去面试的一道上机测试题(凭记忆写的题目)Question:给定输入整数\(\left( k \right)\),找到最小的自然数\(n\left( {n \ge 1} \right)\),使得下列 ...
- 关于微信扫描二维码下载apk文件的细节设计
微信使用的人数越来越多,渐渐的用户形成了一种习惯,扫描二维码的时候,也会打开微信去扫描,但是微信不支持第三方的链接下载,有些厂商已经发现了这一特点,所以在使用二维码下载自家的app时,会做一个提示,引 ...
- 安装完eclipse,dbwear后,需要在他们解压文件.ini下加上你liux的jdk的安装路径,才能正常使用
-vm/usr/java/jdk/jdk1.6.0_45/bin/java