# 60分求救

@阿柒 2020-08-25 10:55 回复

#include<bits/stdc++.h>
using namespace std;
long long x,y,x2,y2,a[10001][10001];
int main()
{
cin>>x>>y>>x2>>y2;
for(int i=0;i<=y;i++) a[0][i]=1;
for(int i=0;i<=x;i++) a[i][0]=1;
a[x2][y2]=-1;
if(x2-2>=0&&y2-1>=0) a[x2-2][y2-1]=-1;
if(x2-2>=0&&y2+1>=0)a[x2-2][y2+1]=-1;
if(x2+2>=0&&y2-1>=0)a[x2+2][y2-1]=-1;
if(x2+2>=0&&y2+1>=0)a[x2+2][y2+1]=-1;
if(x2-1>=0&&y2-2>=0)a[x2-1][y2-2]=-1;
if(x2+1>=0&&y2-2>=0)a[x2+1][y2-2]=-1;
if(x2-1>=0&&y2+2>=0)a[x2-1][y2+2]=-1;
if(x2+1>=0&&y2+2>=0)a[x2+1][y2+2]=-1;
for(int i=1;i<=x;i++)
{
for(int j=1;j<=y;j++)
{
if(a[i][j]==-1) continue;
if(a[i-1][j]==-1&&a[i][j-1]==-1) a[i][j]=0;
else if(a[i-1][j]==-1&&a[i][j-1]!=-1||a[i][j-1]==-1&&a[i-1][j]!=-1) a[i][j]=a[i][j-1]+a[i-1][j]+1;
else a[i][j]=a[i][j-1]+a[i-1][j];
}
}
cout<<a[x][y]<<endl;
return 0;
}

@steve9572 2020-08-30 11:25 回复 举报
#include<bits/stdc++.h>
using namespace std;
long long x,y,x2,y2,a[10001][10001];
int main()
{
cin>>x>>y>>x2>>y2;

a[x2][y2]=-1;
if(x2-2>=0&&y2-1>=0) a[x2-2][y2-1]=-1;
if(x2-2>=0&&y2+1>=0)a[x2-2][y2+1]=-1;
if(x2+2>=0&&y2-1>=0)a[x2+2][y2-1]=-1;
if(x2+2>=0&&y2+1>=0)a[x2+2][y2+1]=-1;
if(x2-1>=0&&y2-2>=0)a[x2-1][y2-2]=-1;
if(x2+1>=0&&y2-2>=0)a[x2+1][y2-2]=-1;
if(x2-1>=0&&y2+2>=0)a[x2-1][y2+2]=-1;
if(x2+1>=0&&y2+2>=0)a[x2+1][y2+2]=-1;
for(int i=0;i<=y;i++)
{
if(a[0][i]==-1) break;//控制点 右/下 方 不通
a[0][i]=1;
}
for(int i=0;i<=x;i++)
{
if(a[i][0]==-1) break;//控制点 右/下 方 不通
a[i][0]=1;
}
for(int i=1;i<=x;i++)
{
for(int j=1;j<=y;j++)
{
if(a[i][j]==-1) continue;
if(a[i-1][j]==-1&&a[i][j-1]==-1) a[i][j]=0;
else if(a[i-1][j]==-1&&a[i][j-1]!=-1||a[i][j-1]==-1&&a[i-1][j]!=-1) a[i][j]=a[i][j-1]+a[i-1][j]+1;
else a[i][j]=a[i][j-1]+a[i-1][j];
}
}
cout<<a[x][y]<<endl;
return 0;
}