过河卒
作者:互联网
#include <bits/stdc++.h>
using namespace std;
int main()
{
int ax,ay,bx,by;
cin>>ax>>ay>>bx>>by;
int arr[ax+5][ay+5];
ax += 2;
ay += 2;
bx += 2;
by += 2;
memset(arr,0,sizeof(arr));
for(int i=0;i<=ax+2;i++)
for(int j=0;j<=ay+2;j++)
if(i==0||i==1||i==ax+1||i==ax+2||j==0||j==1||j==ay+1||j==ay+2) arr[i][j] = -1;
arr[bx][by] = -1;
arr[bx+1][by-2] = -1;
arr[bx+2][by-1] = -1;
arr[bx+2][by+1] = -1;
arr[bx+1][by+2] = -1;
arr[bx-1][by+2] = -1;
arr[bx-2][by+1] = -1;
arr[bx-2][by-1] = -1;
arr[bx-1][by-2] = -1;
arr[2][2] = 1;
for(int i=2;i<=ax;i++)
for(int j=2;j<=ay;j++)
{
if(arr[i][j]<0) continue;
if(arr[i-1][j]>0) arr[i][j] += arr[i-1][j];
if(arr[i][j-1]>0) arr[i][j] += arr[i][j-1];
}
cout<<arr[ax][ay]<<endl;
return 0;
}
标签:std,arr,过河,int,ay,ax,bx 来源: https://www.cnblogs.com/deathgun/p/15600861.html