poj 1657 Distance on Chessboard
2012-02-09 18:26
483 查看
王:横、直、斜都可以走,但每步限走一格。
后:横、直、斜都可以走,每步格数不受限制。
车:横、竖均可以走,不能斜走,格数不限。
象:只能斜走,格数不限。
后:横、直、斜都可以走,每步格数不受限制。
车:横、竖均可以走,不能斜走,格数不限。
象:只能斜走,格数不限。
#include <stdio.h> #include<math.h> int main(int argc, char *argv[]) { int T,x,y; char begin[5],end[5]; scanf("%d",&T); while(T--) { scanf("%s %s",begin,end); x=abs(begin[0]-end[0]); y=abs(begin[1]-end[1]); if(x==0 && y==0) printf("0 0 0 0\n"); 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 && x!=y) printf(" 2\n"); else if(x==y) printf(" 1\n"); else printf(" Inf\n");//象 } } return 0; }
相关文章推荐
- poj 1657 Distance on Chessboard
- poj1657——Distance on Chessboard
- poj1657——Distance on Chessboard——简单题
- POJ 1657 Distance on Chessboard 解题报告
- OpenJudge/Poj 1657 Distance on Chessboard
- Distance on Chessboard POJ - 1657 简单模拟
- POJ 1657 Distance on Chessboard
- POJ 1657 Distance on Chessboard(搜索题)
- POJ 1657-Distance on Chessboard(BFS-多种方向不限步数)
- poj 1657 Distance on Chessboard
- poj 1657 Distance on Chessboard
- POJ 1657 Distance on Chessboard 简单的计算问题
- 百炼POJ 1657 Distance on Chessboard 解题报告
- POJ_1657_Distance on Chessboard
- poj 1657 Distance on Chessboard
- POJ 1657 Distance on Chessboard 解题报告
- poj 1657 Distance on Chessboard(模拟贪心)
- POJ 1657 (Distance on Chessboard)
- POJ 1657 Distance on Chessboard
- POJ 百练 1657: Distance on Chessboard