1010 过河卒  2002NOIP全国联赛普及组codevs

题目描述 Description

 如图,A 点有一个过河卒,需要走到目标 B 点。卒行走规则:可以向下、或者向右。同时在棋盘上的任一点有一个对方的马(如上图的C点),该马所在的点和所有跳跃一步可达的点称为对方马的控制点。例如上图 C 点上的马可以控制 9 个点(图中的P1,P2 … P8 和 C)。卒不能通过对方马的控制点。

  棋盘用坐标表示,A 点(0,0)、B 点(n,m)(n,m 为不超过 20 的整数,并由键盘输入),同样马的位置坐标是需要给出的(约定: C不等于A,同时C不等于B)。现在要求你计算出卒从 A 点能够到达 B 点的路径的条数。

1<=n,m<=15

输入描述 Input Description

 键盘输入

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

输出描述 Output Description

  屏幕输出

    一个整数(路径的条数)。

样例输入 Sample Input

 6 6 3 2

样例输出 Sample Output

17

数据范围及提示 Data Size & Hint

如描述

#include<iostream>
#include<cstdio>
using namespace std;
long long int n,m,x,y,map[][],f[][];
int main(){
cin>>n>>m;
cin>>x>>y;
map[x][y]=;
if(x->=&&y->=) map[x-][y-]=;
if(x+>=&&y->=) map[x+][y-]=;
if(x->=&&y+>=) map[x-][y+]=;
if(x+>=&&y+>=) map[x+][y+]=;
if(x->=&&y->=) map[x-][y-]=;
if(x->=&&y+>=) map[x-][y+]=;
if(x+>=&&y->=) map[x+][y-]=;
if(x+>=&&y+>=) map[x+][y+]=;
f[][]=;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++){
if(i==) f[i][j]=max(f[i][j],f[i][j-]);
if(j==) f[i][j]=max(f[i][j],f[i-][j]);
if(i>&&j>) f[i][j]+=f[i-][j]+f[i][j-];
if(map[i][j]==) f[i][j]=;
}
cout<<f[n][m];
}

简单的棋盘DP,别忘了开long long,重要的话说三遍,别忘了开long long,别忘了开long long。

最新文章

  1. 【代码笔记】iOS-获得现在的日期
  2. Android系统中自定义按键的短按、双击、长按事件
  3. PCA算法是怎么跟协方差矩阵/特征值/特征向量勾搭起来的?
  4. SharePoint2010母版页想要的定制
  5. Go to the first line OR the last line of the file
  6. 4 c#
  7. Spring的lazy-init详解
  8. javadoc简介
  9. 【百度地图API】今日小年大进步,齐头共进贺佳节——API优化升级上线,不再增加内存消耗
  10. 2304: Lights Out(枚举)
  11. C# post提交
  12. c语言贪吃蛇详解5.GameOver功能与显示成绩
  13. 在Android中使用AlarmManager
  14. 瞎捣鼓的code highlight
  15. 玩转CSS3(二)---CSS3实现瀑布布局
  16. redis 查找附近的人
  17. SVN中英文菜单对照
  18. Hash索引和BTree索引
  19. Debug Dart at External Terminal
  20. 迷你MVVM框架 avalonjs 1.3.4发布

热门文章

  1. BFS(两点搜索) UVA 11624 Fire!
  2. Android 性能优化(12)网络优化( 8)Monitoring the Battery Level and Charging State
  3. 《从Paxos到ZooKeeper 分布式一致性原理与实践》阅读【Watcher】
  4. hihocoder offer收割编程练习赛13 D 骑士游历
  5. Java线程及Jvm监控工具
  6. 前端er怎样操作剪切复制以及禁止复制+破解等
  7. Angular——路由参数
  8. Java软件开发中迭代的含义
  9. Analysis of container and Injection in Java, their history and future.
  10. MONO Design创建电信3D机房