#include <iostream>
#include <string>
#define LL long long
#define MAXN 100
using namespace std; int dis[][] = {,,,}; int _m[MAXN][MAXN];
LL dp[MAXN][MAXN];
struct node
{
int x;
int y;
};
int n;
LL dfs(node _node);
//bool mark[MAXN][MAXN];
int main()
{
//freopen("acm.acm","r",stdin); int i;
int j;
string s;
while(cin>>n)
{
getchar();
if(n == -)
{
break;
}
memset(dp,,sizeof(dp));
for(i = ; i < n; ++ i)
{
getline(cin,s);
for(j = ; j < n; ++ j)
{
//cin>>_m[i][j];
_m[i][j] = s[j]-'';
}
} node b;
b.x = ;
b.y = ;
cout<<dfs(b)<<endl;
}
} LL dfs(node _node)
{
if(_node.x == n- && _node.y == n-)
{
return ;
}
if(_m[_node.x][_node.y] == )
{
return ;
}
node temp;
temp.x = _node.x+_m[_node.x][_node.y];
temp.y = _node.y;
if(temp.x < n)
{
if(dp[temp.x][temp.y] == )
{
dp[_node.x][_node.y] += dfs(temp);
}
else
{
dp[_node.x][_node.y] += dp[temp.x][temp.y];
}
}
temp.x = _node.x;
temp.y = _node.y+_m[_node.x][_node.y];
if(temp.y < n)
{
if(dp[temp.x][temp.y] == )
{
dp[_node.x][_node.y] += dfs(temp);
}
else
{
dp[_node.x][_node.y] += dp[temp.x][temp.y];
}
} return dp[_node.x][_node.y];
}

POJ 2704的更多相关文章

  1. POJ 2704 Pascal's Travels 【DFS记忆化搜索】

    题目传送门:http://poj.org/problem?id=2704 Pascal's Travels Time Limit: 1000MS   Memory Limit: 65536K Tota ...

  2. poj 2704 Pascal's Travels_记忆化搜索

    一道简单但是题意蛋疼的题目 题意:给你个n*n的图,开始在左上角,要求走到右下角有多种走法,图上的数表示走几步,只能向右或向下走. #include<iostream> #include& ...

  3. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  4. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  5. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  6. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  7. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  8. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  9. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

随机推荐

  1. 关于Cell中的各种值的类型判断

    switch (cell.getCellType()){ case Cell.CELL_TYPE_NUMERIC: //数字 cellValue = stringDateProcess(cell); ...

  2. Latex表格插入

    \begin{table}[h] \centering \caption{Traffic flows description} \begin{tabular}{|c||c|c|c|c|} \hline ...

  3. 谈谈thinkphp5.1中容器(Container)和门面(Facade)的实现

    tp5.1中引入了容器(Container)和门面(Facade)这两个新的类 官方文档已经给出了定义: 容器(Container)实现类的统一管理,确保对象实例的唯一性. 门面(Facade)为容器 ...

  4. extern声明全局变量用法

    在类之外声明一个成员变量,如: a.h CString name; class a{ }; a.cpp extern CString name; 然后就可以用name这个成员变量了. b.cpp ex ...

  5. HDU 1536 S-Nim (组合游戏+SG函数)

    题意:针对Nim博弈,给定上一个集合,然后下面有 m 个询问,每个询问有 x 堆石子 ,问你每次只能从某一个堆中取出 y 个石子,并且这个 y 必须属于给定的集合,问你先手胜还是负. 析:一个很简单的 ...

  6. 同时安装python2.7和python3.5

    同时安装python2.7和python3.5,并配置sublime ctrl+B选择运行python版本 安装python 首先是安装两个版本的python,并配置相应的环境变量 1.在下载安装好P ...

  7. C++类、继承、多态、虚函数

    一个比较好的虚函数例子 /****************************/ /* 作者:骆天 */ /* 时间:2018/1/26 */ /* 代码:多态的理解 */ /********** ...

  8. Web结构组件

    一.Web结构组件 1.代理 位于客户端和服务器之间的HTTP实体,接收客户端的所有HTTP请求,并将这些请求转发给HTTP服务器. 2.缓存 HTTP的仓库,使常用的页面的副本可以保存在离客户端更近 ...

  9. Mysql逻辑分层、存储引擎

    Mysql的逻辑分层: 连接层 服务层 引擎层 存储层 常见的数据库引擎有InnorDB和MylSAM. InnorDB:事物优先,(适合高并发操作:行锁,顾名思义一次锁一行数据) MylSAM:性能 ...

  10. Hdu1054 Strategic Game(最小覆盖点集)

    Strategic Game Problem Description Bob enjoys playing computer games, especially strategic games, bu ...