Title DescriptionDescription
, a point has a river stroke, need to go to target point B. Stroke rule: can be down, or to the right. At the same time on the board at any point there is a horse (such as the C point), the point where the horse is located and all jumps one step up to the point known as the other horse's control points. For example, a horse on a C point can control 9 points (the p1,p2 in the picture ...). P8 and C). The stroke cannot pass through the other horse's control point.
The chessboard coordinates, A point (0,0), B Point (N,m) (N,m is not more than 20 integer, and by the keyboard input), the same position coordinates of the horse is required (convention: C is not equal to a, and C is not equal to B). You are now asked to calculate the number of strokes from the point where a is able to reach point B.
1<=n,m<=15
Enter a descriptionInput Description
Keyboard input
Coordinates of Point B (n,m) and coordinates of the opponent's horse (x, y) {no error}
Output descriptionOutput Description
Screen output
An integer (the number of bars in the path).
Sample inputSample Input
6 6 3 2
Sample outputSample Output
17
Data range and TipsData Size & Hint
As described
Exercises
Recursion.
Using F "i,j" means the number of methods that go from the i,j to the i,j (if the point is controlled by a horse), the state transition equation is "f" = 0, "=f", "I-1,j" +f "I,j".
var n,m,x,y,i,j:longint;
A:array[-2..21,-2..21]of Boolean;
F:array[-1..21,-1..21]of Int64;
Begin
READLN (N,m,x,y);
A[x,y]:=true;
A[x-2,y-1]:=true;
A[x-2,y+1]:=true;
A[x-1,y-2]:=true;
A[x-1,y+2]:=true;
A[x+1,y-2]:=true;
A[x+1,y+2]:=true;
A[x+2,y-1]:=true;
A[x+2,y+1]:=true;
F[0,0]:=1;
For i:=0 to N do
For j:=0 to M do
Begin
If I+j=0 then continue;
If A[i,j]=false then f[i,j]:=f[i-1,j]+f[i,j-1];
End
Write (f[n,m]);
End.
2002 Cross-River Stroke