POJ 2704
#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的更多相关文章
- POJ 2704 Pascal's Travels 【DFS记忆化搜索】
题目传送门:http://poj.org/problem?id=2704 Pascal's Travels Time Limit: 1000MS Memory Limit: 65536K Tota ...
- poj 2704 Pascal's Travels_记忆化搜索
一道简单但是题意蛋疼的题目 题意:给你个n*n的图,开始在左上角,要求走到右下角有多种走法,图上的数表示走几步,只能向右或向下走. #include<iostream> #include& ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
随机推荐
- 2018.06.26 NOIP模拟 纪念碑(线段树+扫描线)
题解: 题目背景 SOURCE:NOIP2015−GDZSJNZXSOURCE:NOIP2015-GDZSJNZXSOURCE:NOIP2015−GDZSJNZX(难) 题目描述 2034203420 ...
- jquery 特效
http://demo.howtoexe.com/instagram-gravity-gallery/index.html
- 通过html文件生成PDF文件
/// <summary> /// 获取html内容,转成PDF(注册) /// </summary> public void DownloadPDFByHTML(string ...
- (5)How to let go of being a "good" person — and become a better person
https://www.ted.com/talks/dolly_chugh_how_to_let_go_of_being_a_good_person_and_become_a_better_perso ...
- mmm和mmma的区别
m:编译整个安卓系统 makes from the top of the tree mm:编译当前目录下的模块,当前目录下需要有Android.mk这个makefile文件,否则就往上找最近的Andr ...
- 安卓 build/core/Makefile 以及main.mk
android make 系统总共分为四层 arch board device product 在各个字android.mk文件中引用的定义都存放在./build/core/下!比如android.m ...
- flex 布局 计算器
flex布局计算器 <!doctype html> <html> <head> <style> .box{ display: flex; flex-di ...
- 好文推荐系列--------(3)GruntJS 在线重载 提升生产率至新境界
好文原文地址:http://segmentfault.com/a/1190000000354555 本文将首先介绍grunt-markdown插件如何配合HTML模板使用,接着我将介绍如何使用grun ...
- 关于TM影像各波段组合的简介
321:真彩色合成,即3.2.1波段分别赋予红.绿.蓝色,则获得自然彩色合成图像,图像的色彩与原地区或景物的实际色彩一致,适合于非遥感应用专业人员使用. 432:标准假彩色合成,即4.3.2波段分别赋 ...
- cJSON精度丢失问题
问题复现步骤:1) 输入字符串:{ "V":0.12345678}2) 字符串转成cJSON对象3) 调用cJSON_Print将cJSON对象再转成字符串4) 再将字符串转 ...