风的方向 厚德致远，博学敦行！

Time Limit:1000MS  Memory Limit:65536K
Total Submit:691 Accepted:155

Description

```           1   2   3   4   5   6   7    8
A +---+---+---o---+---o---+---+----+--------->Y
|   |   |   |   |   |   |   |    |
1 +---+---o---+---+---+---o---+----+
|   |   |   |   |   |   |   |    |
2 +---+---+---+---C---+---+---+----+
|   |   |   |   |   |   |   |    |
3 +---+---o---+---+---+---o---+----+
|   |   |   |   |   |   |   |    |
4 +---+---+---o---+---o---+---+----+ B(4,8)
|
|
V

X
```

Input

B点坐标（n,m）以及对马的坐标（X,Y）{不用判错}

Output

Sample Input

`6 6 3 2 `

Sample Output

`17`
`         这个题目还是不错的。。。`
`代码如下：`
```#include<stdio.h>int s[21][21];__int64 c[21][21];int a0[8]={-2,-2,-1,-1,1,1,2,2};int b0[8]={1,-1,2,-2,2,-2,1,-1};int x1,y1;int x3,y3;int main(){    int x2,y2;    int i,j;    int test;    while((scanf("%d %d %d %d",&x1,&y1,&x3,&y3)!=EOF))    {        for(i=0;i<21;i++)            for(j=0;j<21;j++)            {                s[i][j]=1;                c[i][j]=0;            }        s[x3][y3]=0;        for(i=0;i<8;i++)//计算受马控制的点        {            x2=x3+a0[i];            y2=y3+b0[i];            if((x2>=0)&&(y2>=0)&&(y2<=20)&&(x2<=20))            {                s[x2][y2]=0;            }        }        test=1;        for(j=0;j<21;j++)//初始化边上的走法        {            if(test)            {                if(s[0][j]==0)                {                    test=0;                }                else                {                    c[0][j]=1;                }            }        }        test=1;        for(j=0;j<21;j++)        {            if(test)            {                if(s[j][0]==0)                {                    test=0;                }                else                {                    c[j][0]=1;                }            }        }        for(i=1;i<21;i++)//计算一个点上的走法，上方点的走法数+左方点的走法数            for(j=1;j<21;j++)            {                if(s[i][j])                {                                        c[i][j]=c[i-1][j]*s[i-1][j]+c[i][j-1]*s[i][j-1];                }            }                    printf("%I64d\n",c[x1][y1]);     }    return 0;}
```
posted on 2010-09-19 09:45 jince 阅读(1259) 评论(2)  编辑 收藏 引用 所属分类: Questions

FeedBack:
# re: 过河卒
2015-06-15 20:54 | cs

# re: 过河卒[未登录]
2015-06-15 21:06 | jince
@cs

回复  更多评论