记录编号 |
107450 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[POJ1657] 棋盘上的距离 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.004 s |
提交时间 |
2014-06-25 21:55:52 |
内存使用 |
0.28 MiB |
显示代码纯文本
- #include<iostream>
- #include <cstdio>
- #include <cmath>
- using namespace std;
- int main()
- {
- freopen("poj_1657.in","r",stdin);
- freopen("poj_1657.out","w",stdout);
- char ch[10];
- int fx,fy;
- int tx,ty;
- int cases;
- int a,b,c,k;
- cin>>cases;
- for(k=1;k<=cases;k++)
- {
- cin>>ch;
- fx=ch[0]-96;
- fy=ch[1]-'0';
- cin>>ch;
- tx=ch[0]-96;
- ty=ch[1]-'0';
- a=abs(fx-tx);
- b=abs(fy-ty);
- if (a<b) cout<<b<<' ';
- else cout<<a<<' ';
- if (fx==tx&&fy==ty) cout<<'0'<<' ';
- else
- if (fx==tx||fy==ty||fx-fy==tx-ty||fx+fy==tx+ty) cout<<'1'<<' ';
- else cout<<'2'<<' ';
- if (fx==tx&&fy==ty) cout<<'0'<<' ';
- else
- if (fx==tx||fy==ty) cout<<'1'<<' ';
- else cout<<"2 ";
- int k=fx+fy-tx-ty;
- if (k<0)k=-k;
- if (k%2==1) cout<<"Inf"<<endl;
- else if(fx==tx&&fy==ty) cout<<'0'<<endl;
- else if(fx-fy==tx-ty||fx+fy==tx+ty) cout<<'1'<<endl;
- else cout<<"2"<<endl;
- }
- }