hooray!
查看原帖
hooray!
602932
NumberTrart楼主2022/7/7 17:00
#include <iostream>
#include<cstring>
using namespace std;
int n,m,x,y;
long long a[25][25]={0};
int gcnt=0;
void _(int x,int y)
{
    if(x>=0 && y>=0 && x<=n && y<=m)
        a[x][y]=0;
}
int main()
{
    memset(a,-1,sizeof(a));
    cin>>n>>m>>x>>y;
    // P P
    //P   P
    //  C
    //P   P
    // P P
    _(x+  0,y+  0);
    _(x+ -2,y+  1);
    _(x+ -1,y+  2);
    _(x+  1,y+  2);
    _(x+  2,y+  1);
    _(x+  2,y+ -1);
    _(x+  1,y+ -2);
    _(x+ -1,y+ -2);
    _(x+ -2,y+ -1);
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            if(a[i][j]==-1)
                if(i==0)
                {
                    if(j==0)
                        a[i][j]=1;
                    else
                        a[i][j]=a[i][j-1];
                }
                else
                {
                    if(j==0)
                        a[i][j]=a[i-1][j];
                    else
                        a[i][j]=a[i][j-1]+a[i-1][j];
                }
    if(a[n][m]==-1) a[n][m]=0;
    cout<<a[n][m];
    return 0;
}

用标数法(数学)解决 happy

2022/7/7 17:00
加载中...