您的位置:首页 > 其它

POJ1657-Distance on Chessboard

2013-09-01 12:16 357 查看
【题目来源】http://poj.org/problem?id=1657

【水题】

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int t;
cin>>t;
char x1,x2;
int y1,y2;
while (t--)
{
cin>>x1>>y1>>x2>>y2;
int dx=abs(x1-x2);
int dy=abs(y1-y2);
if (dx==0 && dy==0)
cout<<"0 0 0 0"<<endl;
else
{
//king
cout<<min(dx,dy)+abs(dx-dy)<<' ';
//queen
if (dx==dy || dx==0 || dy==0)
cout<<1<<' ';
else
cout<<2<<' ';
//castle
if (dx==0 || dy==0)
cout<<1<<' ';
else
cout<<2<<' ';
//elephant
if (abs(dx-dy)%2 !=0)
cout<<"Inf"<<endl;
else if (dx==dy)
cout<<1<<endl;
else
cout<<2<<endl;
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  水题