# 全部TLE！！！求助大佬

@苏晨阳 2021-07-27 23:12 回复
#include<bits/stdc++.h>
using namespace std;

int main()
{
int s[40][40];
int a,b,c,d;

cin>>a>>b>>c>>d;

for(int i=0 ; i<=40 ; i++)
{
for(int j=0 ; j<=40 ; j++)
{
s[i][j] = 1;
}
}

s[c-2][d+1] = s[c-1][d+2] = s[c+2][d+1] = s[c+1][d-2] = -1;
s[c-2][d-1] = s[c-1][d-2] = s[c+2][d-1] = s[c+1][d-2] = s[c][d] = -1;

for(int i=0 ; i<=a ; i++)
{
for(int j=1 ; j<=b ; j++)
{
if( s[i][j] == -1 && s[i+1][j-1] != -1) s[i+1][j] = s[i+1][j-1];
else if( s[i+1][j-1] == -1 && s[i][j] != -1) s[i+1][j] = s[i][j];
else if( s[i][j] == -1 && s[i+1][j-1] == -1) s[i+1][j] = 0;
else if( s[i][j] != -1 && s[i+1][j-1] != -1) s[i+1][j] = s[i+1][j-1] + s[i][j];
}
}

cout<<s[a][b]<<endl;
return 0;
}
@摸鱼_ 2021-07-30 18:25 回复 举报
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n[105][105];
int a,b,c,d;
cin>>a>>b>>c>>d;
for(int i=1;i<=a;i++){
if((i==c && d==0) || (i==c-1 && d-2==0) || (i==c-2 && d-1==0) || (i==c+2 && d-1==0) || (i==c+1 && d-2==0)){
for(int j=i;j<=a;j++){
n[j][0]=0;
}
break;
}else{
n[i][0]=1;
}
}
for(int i=1;i<=b;i++){
if((c==0 && i==d) || (c-1==0 && i==d-2) || (c-2==0 && i==d-1) || (c-1==0 && i==d+2) || (c-2==0 && i==d+1)){
for(int j=i;j<=b;j++){
n[0][j]=0;
}
break;
}else{
n[0][i]=1;
}
}
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
if((i==c && j==d) || (i==c+1 && j==d+2) || (i==c+2 && j==d+1) || (i==c+1 && j==d-2) || (i==c+2 && j==d-1) || (i==c-1 && j==d+2) || (i==c-2 && j==d+1) || (i==c-1 && j==d-2) || (i==c-2 && j==d-1)){
n[i][j]=0;
}else{
n[i][j]=n[i-1][j]+n[i][j-1];
}
}
}
cout<<n[a][b];
return 0;
}
@摸鱼_ 2021-07-30 18:31 回复 举报