标签:
题目链接:
题意:
给出king的位置,问有几个可移动的位置;
思路:
水题,没有思路;
AC代码:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<‘0‘||CH>‘9‘;F= CH==‘-‘,CH=getchar()); for(num=0;CH>=‘0‘&&CH<=‘9‘;num=num*10+CH-‘0‘,CH=getchar()); F && (num=-num); } int stk[70], tp; template<class T> inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + ‘0‘); putchar(‘\n‘); } const LL mod=1e9+7; const double PI=acos(-1.0); const int inf=1e9; const int N=1e5+10; const int maxn=1e3+20; const double eps=1e-12; char s[5]; int getans(char x,char y) { int flag=0; if(x==‘a‘||x==‘h‘)flag++; if(y==‘1‘||y==‘8‘)flag++; if(flag==0)return 8; else if(flag==1)return 5; else return 3; } int main() { scanf("%s",s); cout<<getans(s[0],s[1]); return 0; }
codeforces 710A A. King Moves(水题)
标签:
原文地址:http://www.cnblogs.com/zhangchengc919/p/5801116.html