卡在3、4,已用long long求助
查看原帖
卡在3、4,已用long long求助
1037502
luxiaomao楼主2023/7/12 14:29
#include<bits/stdc++.h>
using namespace std;


int main(){
    int bx,by,hx,hy;
    scanf("%d%d%d%d",&bx,&by,&hx,&hy);
    
    long long line[bx+1][by+1];
    for(int i = 0;i <= bx;i++)
    {
        for(int j = 0;j <= by;j++)
        {
            line[i][j] = 0;
        }
    }
    line[0][0] = 1;
    
    line[hx][hy] = -1;
    line[hx-2][hy-1] = -1;
    line[hx-2][hy+1] = -1;
    line[hx-1][hy-2] = -1;
    line[hx-1][hy+2] = -1;
    line[hx+1][hy-2] = -1;
    line[hx+1][hy+2] = -1;
    line[hx+2][hy-1] = -1;
    line[hx+2][hy+1] = -1;
    
    for(int i = 0;i <= bx;i++)
    {
        for(int j = 0;j <= by;j++)
        {
            if(line[i][j]==-1)continue;
            if(i != 0 && line[i-1][j]!=-1)line[i][j]+=line[i-1][j];
            if(j != 0 && line[i][j-1]!=-1)line[i][j]+=line[i][j-1];
        }
    }
    printf("%lld",line[bx][by]);
    return 0;
}
2023/7/12 14:29
加载中...