That Italy: N × M grid which has a broken edge, and asked to put the number of the process from start to finish.
Analysis: mathematical formulas
If no bad side, then the total number of discharge method is a C N-. 1 (M + N-2)
Because each method should take the (M + N-2) step, step M-1 to go up, go right step N-1
Now consider a bad side, then calculate the bad side through this program then subtracted from the total number of bad passes inside edge solutions to a number
After several bad program from the beginning to the edge is (x1, y1) × number of programs from (x2, y2) to the end of the program number
1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <iostream> 5 #include <algorithm> 6 #include <queue> 7 #include <cstdlib> 8 #include <vector> 9 #include <set> 10 #include <map> 11 #define LL long long 12 #define mod 1000000007 13 #define inf 0x3f3f3f3f 14 #define N 10010 15 using namespace std; 16 LL c[50][50]; 17 void init() 18 { 19 for(int i=0;i<=40;i++)c[i][0]=c[i][i]=1; 20 for(int i=1;i<=40;i++) 21 for(int j=1;j<i;j++)c[i][j]=c[i-1][j]+c[i-1][j-1]; 22 } 23 int main() 24 { 25 int n,m,x1,y1,x2,y2; 26 init(); 27 while(scanf("%d%d",&n,&m)>0) 28 { 29 scanf("%d%d%d%d",&x1,&y1,&x2,&y2); 30 if(x1+y1>x2+y2) 31 { 32 swap(x1,x2); 33 swap(y1,y2); 34 } 35 printf("%I64d\n",c[n+m-2][m-1]-c[x1+y1][x1]*c[m+n-2-x2-y2][m-1-x2]); 36 } 37 }