#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. hdu-1059(多重背包+二进制优化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1059 题意:输入6个数,每个数ni代表价值为i的物品有ni个.求如果这些物品能均分给两个人,每个人获得 ...

  2. SPRING 集成 activemq 的 topic 模式

    概要 activemq 支持两种模式: 1.队列模式 2. 发布订阅者模式,topic有一个主题可以有多个订阅者.这种情况可以将一个消息,分发到多个消费者. 比如我有这样一个案例,用户需要同步,而且需 ...

  3. jquery特殊字符转义方法

    //特殊字符转义function escapeJquery(srcString) { // 转义之后的结果 var escapseResult = srcString; // javascript正则 ...

  4. js监听键盘触发按钮事件,回车提交表单

    /*回车提交表单*/ $(document).keydown(function(event){ if(event.keyCode == 13){ //alert('你按下了Enter'); $(&qu ...

  5. 学以致用十八-----shell脚本之基础概念及变量

    1.脚本脚本,说了很多年的脚本,一直都没怎么弄明白为什么叫脚本,还仅仅是script翻译过来的?今天再查看翻译,查阅了资料,对脚本有了个新的认识. script也叫剧本,脚本---剧本,像剧本一样,让 ...

  6. tokudb_tmp_dir导致的tokudb加载失败

    安装TOKUDB数据库,安装完成后为了使配置生效,重启完数据库后,发现: mysql> show engines; +--------------------+---------+ | Engi ...

  7. java 获取浏览器类型

    public String getBrowserType(HttpServletRequest request)   {     String type = "ie";     S ...

  8. 基础总结篇之一:Activity生命周期[转]

    from:http://blog.csdn.net/liuhe688/article/details/6733407   基础总结篇之一:Activity生命周期 子曰:溫故而知新,可以為師矣.< ...

  9. Shell编程-12-Shell脚本规范及调试

    目录 Shell脚本规范 Shell脚本调试 Shell脚本规范     良好的代码规范不仅方便阅读,也利于维护和提升开发效率.因此建议大家在编写Shell脚本时养成良好的代码习惯.今天就和大家探讨一 ...

  10. spring的bean在什么时候被实例化

    Spring什么时候实例化bean,首先要分2种情况   第一:如果你使用BeanFactory作为Spring Bean的工厂类,则所有的bean都是在第一次使用该Bean的时候实例化   第二:如 ...