UVA - 825 Walking on the Safe Side
来源:互联网 发布:seo文章编辑器 编辑:程序博客网 时间:2024/05/14 18:35
题目大意:给出n,m,现在给出n行数据, 每行有k(k为不定值)个数字, 第一个数字代表行数, 后面k - 1个数代表当前行的这个位置不可走, 问有多少路径可以从(1,1)到(n,m),只能向下或向右。
解题思路:dp[i][j] = dip[i - 1][j] + dp[i][j - 1], 很简单的dp问题。
#include <cstdio>#include <iostream>#include <string>#include <sstream>using namespace std;int main() {int T, cnt = 0;scanf("%d", &T);while (T--) {int temp, R, C, DP[300][300] = {1};char str[200];scanf("%d%d%*c", &R, &C);for (int i = 0; i < R; i++) {string line;getline(cin, line);stringstream ss(line);int temp;ss >> temp;while (ss >> temp)DP[i][temp-1] = -1;}for (int i = 0; i < R; i++)for (int j = 0; j < C; j++)if (DP[i][j] != -1) {if (DP[i][j+1] != -1)DP[i][j+1] += DP[i][j];if (DP[i+1][j] != -1)DP[i+1][j] += DP[i][j];}if (cnt++)printf("\n");printf("%d\n", DP[R-1][C-1]);}return 0;}
0 0
- uva 825 Walking on the Safe Side
- UVA 825 Walking on the Safe Side
- UVa 825 - Walking on the Safe Side
- uva 825 - Walking on the Safe Side
- UVa 825 - Walking on the Safe Side
- UVA-825-Walking on the Safe Side
- UVa:825 Walking on the Safe Side
- UVA - 825 Walking on the Safe Side
- uva 825 Walking on the Safe Side
- UVa 825 - Walking on the Safe Side
- UVA - 825 Walking on the Safe Side
- UVA - 825 Walking on the Safe Side
- uva 825 Walking on the Safe Side
- UVA 825 Walking on the Safe Side
- UVA - 825 Walking on the Safe Side
- dp uva-825-Walking on the Safe Side
- UVa 825 Walking on the Safe Side (DP)
- UVA 825 Walking on the Safe Side(记忆化搜索)
- UVA - 620 Cellular Structure
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- Android UI 优化——使用HierarchyViewer工具
- GUI编程之GridLayout
- netfilter/iptables 结构要点
- UVA - 825 Walking on the Safe Side
- 北京初“探”,还是初“谈”
- 士兵杀敌(一)
- javascript Enumerator
- (hdu step 7.1.7)Wall(求凸包的周长——求将所有点围起来的最小凸多边形的周长)
- UVA - 10534 Wavio Sequence
- MongoDB 集群介绍
- 下载安装Android Studio详细教程
- 【分层图】分层图学习笔记