输入样例
2
a1 c3
f5 f8
输出样例
2 1 2 1
3 1 1 Inf
#include<stdio.h> #include<math.h> int main() { int nCases,i; scanf("%d",&nCases); for(i=0;i<nCases;i++) { char begin[5],end[5]; scanf("%s %s",begin,end); int x,y; x=abs(end[0]-begin[0]); y=abs(end[1]-begin[1]); if(x==0&&y==0) printf("0 0 0 0 "); else{ if(x<y)printf("%d ",y); else printf("%d ",x); if(x==y||x==0||y==0)printf("1 "); else printf(" 2"); if(x==0||y==0)printf("1 "); else printf("2 "); if(abs(x-y)%2!=0)printf("Inf "); else if(x==y) printf("1 "); else printf("2 "); } } return 0; }