Xiao Ming took part in the school's fun games, one of the items is: Jump lattice.
The ground is painted with some squares, each of which is written in a single word, as follows: (see also P1.jpg)
From the start of my vibration
I start a revival.
To do the revitalization of
The rejuvenation of the rejuvenating
Race, first stand in the upper left corner of the word "from" in the lattice, you can jump horizontally or vertically to the adjacent lattice, but can not jump to the diagonal of the lattice or other position. Always have to jump to the end of the word "Hua".
The line required to skip is just the phrase "from my own rejuvenation".
Please help xiaoming calculate how many possible jumps he has altogether.
The answer is an integer, please submit the number directly from the browser.
Note: Do not submit the answer process, or the contents of other auxiliary instruction classes.
The idea of solving problems: to "revitalize New China from me" as "01234567" in the map array. Searches from the upper-left corner (0,0) until the (3,4) is searched.
Import Java.math.BigInteger;
Import Java.util.Arrays;
Import Java.util.HashMap;
Import java.util.LinkedList;
Import Java.util.Map;
Import Java.util.Queue;
Import Java.util.Scanner;
Import Java.util.Stack;
Import Java.util.Vector;
public class Main1 {static Scanner in=new Scanner (system.in);
static int count=0;
Static int[] x={1,0,-1,0};
Static int[] y={0,-1,0,1};
static int map[][]={{0,1,2,3,4},{1,2,3,4,5},{2,3,4,5,6},{3,4,5,6,7}};
static int b[][]=new int[4][5];
public static void Main (string[] args) {//int map[][]=new int[5][5];
B[0][0]=1;
DFS (0,0);
System.out.println (count);
private static void Dfs (int x, int y) {//TODO auto-generated Method stub if (x==3&&y==4) {count++;
Return
for (int i=0;i<4;i++) {int nx=x+x[i];
int ny=y+y[i]; if (nx<0| | nx>=4| | ny<0| |
ny>=5) {continue; } if (Map[x][y]+1==map[nx][ny]&&b[nx][ny]==0) {b[nx][ny]=1;
DFS (NX,NY);
b[nx][ny]=0;
} return; }
}