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 ...
随机推荐
- js二级下拉被flash档住的解决办法
在<object></object>及以内的代码加入到<script>标签对内 <script language="javascript" ...
- php 使用phpmailer 发送邮件(附带中文乱码的解决方法)
下载phpmailer ,在程序里包含class.phpmailer.php 类 ,这里有中文乱码的解决方法 实例代码如下 <html> <head> <title&g ...
- 大数据分析的众包平台—Kaggle
众包(Jeff Howe,2006)是一种在互联网蓬勃发展的背景下产生的一种创新的生产组织形式.在这样的商业模式下,企业利用网络将工作分配出去,通过让更合适的人群参与其中来发现创意和解决技术问题.比较 ...
- textile
textile 编辑 Textile是一个人性化的Web文本生成器,以简洁的方式提供HTML标签功能. 目录 1内容 ▪ 短语修饰符 ▪ 块修饰符 ▪ 链接 ▪ 属性 ▪ 排列 ▪ 表格 ▪ 图像 ...
- web.xml文件的作用
每个javaEE工程中都有web.xml文件,那么它的作用是什么呢?它是每个web.xml工程都必须的吗? 一个web中可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. ...
- oracle sql语句跟踪
select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT from v$sqlarea b order by b.FIRST_LOAD_TIM ...
- hdu 1527(威佐夫博奕)
题意:容易理解. 分析:威佐夫博奕的模板题. 代码实现: #include<stdio.h> #include<string.h> #include<math.h> ...
- Lists
List类主要提供了对List类的子类构造以及操作的静态方法.在类中支持构造ArrayList.LinkedList以及newCopyOnWriteArrayList对象的方法.其中提供了以下构造Ar ...
- jvm调优之四:生产环境参数实例及分析【生产环境实例增加中】
java application项目(非web项目) 改进前: -Xms128m-Xmx128m-XX:NewSize=64m-XX:PermSize=64m-XX:+UseConcMarkSweep ...
- Android中垃圾回收日志信息
原因 GC_CONCURRENTfreed 178K, 41% free 3673K/6151K, external 0K/0K, paused 2ms+2msGC_EXPLICITfreed 6K, ...