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.10.24 bzoj3195: [Jxoi2012]奇怪的道路(状压dp)
传送门 f[i][j][k]f[i][j][k]f[i][j][k]表示前iii个点连了jjj条边,第i−K+1i-K+1i−K+1~iii个点连边数的奇偶性为kkk时的方案数. 转移规定只能从后向前 ...
- C#中string类型是值类型还是引用类型?(转)
出处:https://www.cnblogs.com/dxxzst/p/8488567.html .Net框架程序设计(修订版)中有这样一段描述:String类型直接继承自Object,这使得它成为一 ...
- linux利用命令将一个盘上的所有复制到另一个盘上
1.fdisk -l 查看硬盘状况 2.将目标盘利用mount挂载 3.查看硬盘使用状况,看目标盘是否有足够的空间:df -h 4.如果足够,利用dd命令将源盘数据拷贝到目标盘:dd if=/dev/ ...
- IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA环境搭建,JPA实现非字符型设置长度
1.在github上已有配置环境,如下链接,(需要环境JDK1.8及以上版本,Tomcat1.8及以上版本,搭建maven库,使用编译器IntellJ IDEA) https://github.com ...
- DDR II中的延时参数
CL (CAS latency) CL是从读命令发出到有效数据到DDR端口的延时,以时钟为单位.下图分别表示CL = 3和CL = 4的两种情况, 如果读命令在第n个时钟周期发出,CL = m,则读 ...
- 【慕课网实战】Spark Streaming实时流处理项目实战笔记六之铭文升级版
铭文一级: 整合Flume和Kafka的综合使用 avro-memory-kafka.conf avro-memory-kafka.sources = avro-sourceavro-memory-k ...
- Node的关系型数据库ORM库:bookshelf
NodeJs 关系数据库ORM库:Bookshelf.js bookshelf.js是基于knex的一个关系型数据库的ORM库.简单易用,内置了Promise的支持.这里主要罗列一些使用的例子,例子就 ...
- Java理论学时第六节。课后作业。
package Fuction; class Grandparent { public Grandparent() { System.out.println("GrandParent Cre ...
- Codeforces Round #540 (Div. 3)--1118B - Tanya and Candies(easy TL!)
Tanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai. She plans to eat e ...
- java基础-day9
第09天 java集合 今日内容介绍 u 对象数组 u 集合类之ArrayList u 学生管理系统案例 第1章 对象数组 1.1 对象数组概述 A:基本类型的数组:存储的元素为基本类型 ...