#include <iostream>
using namespace std;
int dx[8]={-1,1,2,2,1,-1,-2,-2};
int dy[8]={2,2,1,-1,-2,-2,-1,1};
bool flag[5][6]={0};
int x0,y0,ans;
void dfs( int x,int y)
{ int x1,y1,i;
for (i=0; i<8; i++)
{
x1=x+dx[i]; y1=y+dy[i];
if (x1==x0 && y1==y0 ) ans++;
else if ( x1<=4 && y1<=5 && x1>=1 && y1>=1 && flag[x1][y1]==0 )
{ flag[x1][y1]=1; dfs(x1,y1); flag[x1][y1]=0;}
}
}
int main(int argc, char *argv[])
{
while (cin>>x0>>y0)
{ ans=0;
dfs(x0,y0);
cout<<ans<<endl;
}
return 0;
}
原文地址:http://www.cnblogs.com/2014acm/p/3891708.html