Your constancy, why shift up just before dawn sleep, the most useless, MO a day exposure 10th cold.
Question I: "Backtracking" horse to stop crossing the river and stroke
"Backtracking" horse block crossing time limit: 1 Sec memory limit: MB commit: 11 [Submit] [status] [discussion version] Title DescriptionA point on the board has a river stroke, need to go to target point B. Rule of stroke: can be down, or to the right. At the same time on the Chessboard C Point has a side of the horse, the point where the horse is located and all jumps step up to the point known as the other horse's control points. So called "Horse Block crossing the river." The chessboard is represented by coordinates, point a (0, 0), B (n, m) (N, M is not more than 20 integers), and the position coordinates of the same horse need to be given. Now ask you to calculate the number of strokes from point A to point B, assuming that the position of the horse is fixed, and that the horse is not walking one step at a time. Input
A row of four data, representing the coordinates of the B point and the horse's coordinates, respectively. (All data is guaranteed to be solved)
Output
A data that represents all the number of path bars.
Sample input
6 6 3 3
Sample output
6
Actually put N and m input in reverse .... For a half-day error Leng didn't see
#include <iostream>#include<cstring>using namespacestd;Long Longf[ -][ -];inta[ -][ -],m,n,x,y;intzx[8]={-2,-1,1,2,2,1,-1,-2},zy[8]={-1,-2,-2,-1,1,2,2,1};intMain () {CIN>>n>>m>>x>>y; Memset (F,0,sizeof(f)); Memset (A,0,sizeof(a)); A[x+1][y+1]=1; for(intI=0;i<8; i++) { if(x+zx[i]>=0&&y+zy[i]>=0) A[x+zx[i]+1][y+zy[i]+1]=1; } f[1][1]=1; for(intI=1; i<=n+1; i++) { for(intj=1; j<=m+1; j + +) { if(i==1&&j==1)Continue; if(a[i][j]==1)Continue; F[I][J]=f[i-1][j]+f[i][j-1]; }} cout<<f[n+1][m+1]<<Endl; return 0;}
View Code
"Backtracking" horse stopped crossing the river to stroke