Code Vs 1010 过河卒

[Uncompleted]

http://codevs.cn/problem/1010/

#include <stdio.h>
#include<string.h>
#define x 0
#define y 1
int map[20][20];
void Print(int h[][2])
{
    int i;
    for(i=0;i<9;i++)
    {
        printf("%d %d ",h[i][x],h[i][y]);
    }
}
int main()
{
    int bn,bm;
    int h[2];
    memset(map,0,20*20);
    
    scanf("%d%d",&bn,&bm);
    scanf("%d%d",&h[x],&h[y]);
    
    map[h[x]][h[y]]=-1;
    map[h[x]+2][h[y]+1]=-1;
    map[h[x]+2][h[y]-1]=-1;
    map[h[x]+1][h[y]-2]=-1;
    map[h[x]-1][h[y]-2]=-1;
    map[h[x]-2][h[y]-1]=-1;
    map[h[x]-2][h[y]+1]=-1;
    map[h[x]-1][h[y]+2]=-1;
    map[h[x]+1][h[y]+2]=-1;
    
    int i,j;
    map[0][0]=1;
    for(i=0;i<=bn;i++)
    {
        for(j=0;j<=bm;j++)
        {
            if(map[i][j]==-1)continue;
            if(j>0&&map[i][j-1]!=-1)map[i][j]+=map[i][j-1];
            if(i>0&&map[i-1][j]!=-1)map[i][j]+=map[i-1][j];
        }
    }
    int ans=map[bn][bm];
    printf("%d ",ans);
    return 0;
}

原文地址:https://www.cnblogs.com/CXSheng/p/4926362.html