zoukankan      html  css  js  c++  java
  • 【模拟】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 #include<string>
     7 #include<iomanip>
     8 #include<map>
     9 #include<memory.h>
    10 #include<time.h>
    11 #include<stdio.h>
    12 #include<stdlib.h>
    13 #include<string.h>
    14 //#include<stdbool.h>
    15 #include<math.h>
    16 #define min(a,b) ((a)<(b)?(a):(b))
    17 #define max(a,b) ((a)>(b)?(a):(b))
    18 #define abs(a) ((a)>0?(a):(-(a)))
    19 #define lowbit(a) (a&(-a))
    20 #define sqr(a) ((a)*(a))
    21 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
    22 #define mem(a,b) memset(a,b,sizeof(a))
    23 #define eps (1e-8)
    24 #define J 10
    25 #define mod 1000000007
    26 #define MAX 0x7f7f7f7f
    27 #define PI 3.14159265358979323
    28 #define N 10004
    29 using namespace std;
    30 typedef long long LL;
    31 int cas,cass;
    32 int n,m,lll,ans;
    33 char ch;
    34 int main()
    35 {
    36     #ifndef ONLINE_JUDGE
    37 //    freopen("1.txt","r",stdin);
    38 //    freopen("2.txt","w",stdout);
    39     #endif
    40     int i,j,k;
    41 //    for(scanf("%d",&cas);cas;cas--)
    42 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
    43 //    while(~scanf("%s",s+1))
    44 //    while(~scanf("%d",&n))
    45 //    {
    46     cin>>ch>>n;
    47     ans=8;
    48     if(ch=='a' || ch=='h')ans-=3;
    49     if(n==1 || n==8)ans-=3;
    50     if((n==1 || n==8) && (ch=='a' || ch=='h'))ans++;
    51     printf("%d
    ",ans);
    52 //    }
    53     return 0;
    54 }
    55 /*
    56 //
    57 
    58 //
    59 */
    View Code
  • 相关阅读:
    List和Dictionary互转
    table html
    华为解锁BL
    安卓小米系统开发一些适配问题
    02布局总结
    02表格布局
    02Framelayout:帧布局
    02线性布局
    02相对布局
    01安卓像素 dpi 、 dip 、分辨率、屏幕尺寸、px、density 关系以及换算
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5797773.html
Copyright © 2011-2022 走看看