poj 1657(模拟,注意象的判定)

#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int n,a,b,c,d;
    char start[25][3],end[25][3];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%s%s",start[i],end[i]);
        int x = abs(start[i][0]-end[i][0]);
        int y = abs(start[i][1]-end[i][1]);
        
        if(x==0&&y==0){
            a = b = c = d = 0; 
        }
        else{
            a = max(x,y);
            if(x==0||y==0||x==y)b = 1;
            else                 b = 2;
            if(x==0||y==0)    c = 1;
            else             c = 2;
            if((x+y)%2==0){
                if(x==y)    d = 1;
                else        d = 2;
            }
            else            d = -1;
        }
        printf("%d %d %d ",a,b,c);
        if(d==-1)    printf("Inf\n");
        else        printf("%d\n",d);
    }
    return 0;
}

 

上一篇:poj 1969(容易失误,注意顺序,但是不难,是水题)


下一篇:poj 1306(阶乘,大数运算)