题目链接:http://codeforces.com/problemset/problem/38/B
题目大意:给你两颗棋子,分别为车和士,在8*8的方块中,该死了你两颗棋子的位置(这两颗棋子不会受到对方的攻击),要你在摆一颗棋子,问你摆的方法有几种。
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
char c;
int x1,x2,y1,y2,ans=0;
cin>>c>>y1;
x1=c-'a'+1;
cin>>c>>y2;
x2=c-'a'+1;
for(int i=1;i<=8;i++)
for(int j=1;j<=8;j++)
if((i!=x1 || j!=y1)&&(i!=x2 ||j!=y2))
if(i!=x1 && j!=y1)
if((abs(i-x1)!=2 || abs(j-y1)!=1)&&(abs(i-x1)!=1 || abs(j-y1)!=2))
if((abs(i-x2)!=2 || abs(j-y2)!=1)&& (abs(i-x2)!=1 || abs(j-y2)!=2))
ans++;
cout<<ans<<endl;
return 0;
}