1. #include <iostream>
  2. #include <string>
  3. #define LL long long
  4. #define MAXN 100
  5. using namespace std;
  6.  
  7. int dis[][] = {,,,};
  8.  
  9. int _m[MAXN][MAXN];
  10. LL dp[MAXN][MAXN];
  11. struct node
  12. {
  13. int x;
  14. int y;
  15. };
  16. int n;
  17. LL dfs(node _node);
  18. //bool mark[MAXN][MAXN];
  19. int main()
  20. {
  21. //freopen("acm.acm","r",stdin);
  22.  
  23. int i;
  24. int j;
  25. string s;
  26. while(cin>>n)
  27. {
  28. getchar();
  29. if(n == -)
  30. {
  31. break;
  32. }
  33. memset(dp,,sizeof(dp));
  34. for(i = ; i < n; ++ i)
  35. {
  36. getline(cin,s);
  37. for(j = ; j < n; ++ j)
  38. {
  39. //cin>>_m[i][j];
  40. _m[i][j] = s[j]-'';
  41. }
  42. }
  43.  
  44. node b;
  45. b.x = ;
  46. b.y = ;
  47. cout<<dfs(b)<<endl;
  48. }
  49. }
  50.  
  51. LL dfs(node _node)
  52. {
  53. if(_node.x == n- && _node.y == n-)
  54. {
  55. return ;
  56. }
  57. if(_m[_node.x][_node.y] == )
  58. {
  59. return ;
  60. }
  61. node temp;
  62. temp.x = _node.x+_m[_node.x][_node.y];
  63. temp.y = _node.y;
  64. if(temp.x < n)
  65. {
  66. if(dp[temp.x][temp.y] == )
  67. {
  68. dp[_node.x][_node.y] += dfs(temp);
  69. }
  70. else
  71. {
  72. dp[_node.x][_node.y] += dp[temp.x][temp.y];
  73. }
  74. }
  75. temp.x = _node.x;
  76. temp.y = _node.y+_m[_node.x][_node.y];
  77. if(temp.y < n)
  78. {
  79. if(dp[temp.x][temp.y] == )
  80. {
  81. dp[_node.x][_node.y] += dfs(temp);
  82. }
  83. else
  84. {
  85. dp[_node.x][_node.y] += dp[temp.x][temp.y];
  86. }
  87. }
  88.  
  89. return dp[_node.x][_node.y];
  90. }

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. 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时的方案数. 转移规定只能从后向前 ...

  2. C#中string类型是值类型还是引用类型?(转)

    出处:https://www.cnblogs.com/dxxzst/p/8488567.html .Net框架程序设计(修订版)中有这样一段描述:String类型直接继承自Object,这使得它成为一 ...

  3. linux利用命令将一个盘上的所有复制到另一个盘上

    1.fdisk -l 查看硬盘状况 2.将目标盘利用mount挂载 3.查看硬盘使用状况,看目标盘是否有足够的空间:df -h 4.如果足够,利用dd命令将源盘数据拷贝到目标盘:dd if=/dev/ ...

  4. IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA环境搭建,JPA实现非字符型设置长度

    1.在github上已有配置环境,如下链接,(需要环境JDK1.8及以上版本,Tomcat1.8及以上版本,搭建maven库,使用编译器IntellJ IDEA) https://github.com ...

  5. DDR II中的延时参数

     CL (CAS latency) CL是从读命令发出到有效数据到DDR端口的延时,以时钟为单位.下图分别表示CL = 3和CL = 4的两种情况, 如果读命令在第n个时钟周期发出,CL = m,则读 ...

  6. 【慕课网实战】Spark Streaming实时流处理项目实战笔记六之铭文升级版

    铭文一级: 整合Flume和Kafka的综合使用 avro-memory-kafka.conf avro-memory-kafka.sources = avro-sourceavro-memory-k ...

  7. Node的关系型数据库ORM库:bookshelf

    NodeJs 关系数据库ORM库:Bookshelf.js bookshelf.js是基于knex的一个关系型数据库的ORM库.简单易用,内置了Promise的支持.这里主要罗列一些使用的例子,例子就 ...

  8. Java理论学时第六节。课后作业。

    package Fuction; class Grandparent { public Grandparent() { System.out.println("GrandParent Cre ...

  9. 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 ...

  10. java基础-day9

    第09天 java集合 今日内容介绍 u 对象数组 u 集合类之ArrayList u 学生管理系统案例 第1章   对象数组 1.1      对象数组概述 A:基本类型的数组:存储的元素为基本类型 ...