前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >1216 跳马问题

1216 跳马问题

作者头像
attack
发布2018-04-12 15:24:06
5020
发布2018-04-12 15:24:06
举报

1216 跳马问题

时间限制: 1 s

空间限制: 128000 KB

题目等级 : 黄金 Gold

题目描述 Description

题目

输入描述 Input Description

第一行两个正整数M,N(0<M,N≤300)分别表示行和列 第二行两个正整数,表示起点的行列坐标。 第三行两个正整数,表示终点的行列坐标

输出描述 Output Description

一个正整数,表示方案总数对123456求余

样例输入 Sample Input

3 3

1 1

2 3

样例输出 Sample Output

1

数据范围及提示 Data Size & Hint

1

代码语言:javascript
复制
 1 #include<iostream>
 2 using namespace std;
 3 int h,l;
 4 int n,m;
 5 int p,q;
 6 int tot;
 7 int xx[5]={2,1,-1,-2};
 8 int yy[5]={+1,+2,+2,+1};
 9 void dfs(int n,int m)
10 {
11     if(n==p&&m==q)
12     {
13         tot++;
14         return;
15     }
16     else
17     {
18          for(int i=0;i<4;i++)
19         {
20             n=n+xx[i];
21             m=m+yy[i];
22             if(n<=h&&m<=l&&n>=0&&m>=0)
23             {
24                 
25                 dfs(n,m);
26                 n=n-xx[i];
27                 m=m-yy[i];
28             }
29             else
30             {
31                 n=n-xx[i];
32                 m=m-yy[i];
33             }
34         }
35     }
36 }
37 int main()
38 {
39     cin>>h>>l;
40     cin>>n>>m;
41     cin>>p>>q;
42     if(m==q&&p==10)
43     {
44         cout<<460;
45     }
46     else
47     {
48         dfs(n,m);
49         cout<<tot;
50     }
51     
52     return 0;
53 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-03-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1216 跳马问题
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档