1 #include<bits/stdc++.h>
2 using namespace std;
3 int arra[5][5];
4 int visited[5][5];
5 int direction[5][3];
6 int sum=0;
7 void DFS(int x,int y,int step)
8 {
9 cout << step << endl;
10 if(step==1)
11 {
12 sum++;
13 return;
14 }
15 for(int i=1;i<=4;i++)
16 {
17
18 int xx = x+direction[i][1];
19 int yy = y+direction[i][2];
20 if(xx<1||xx>4||yy<1||yy>4||visited[xx][yy]==1)
21 {
22 continue;
23 }
24 visited[xx][yy]=1;
25 DFS(xx,yy,step-1);
26 visited[xx][yy]=0;
27 }
28
29 }
30 int main()
31 {
32 //方向
33 direction[1][1]=1;
34 direction[1][2]=0;
35
36 direction[2][1]=0;
37 direction[2][2]=1;
38
39 direction[3][1]=-1;
40 direction[3][2]=0;
41
42 direction[4][1]=0;
43 direction[4][2]=-1;
44
45 for(int i=1;i<=4;i++)
46 {
47 for(int j=1;j<=4;j++)
48 {
49 visited[i][j]=1;
50 DFS(i,j,16);
51 visited[i][j]=0;
52 }
53 }
54 cout << sum;
55 return 0;
56 }