UVA - 825 Walking on the Safe Side
来源:互联网 发布:价格表制作软件 编辑:程序博客网 时间:2024/05/16 08:12
题意:求从坐标(1,1)到(n,m)的路径数,有些地方是不能走的,输入有点麻烦而已,只能走右或下,所以动态转移方程就很简单了dp[i][j] = dp[i-1][j] + dp[i][j-1]
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN = 1010;char str[MAXN];int n,m,G[MAXN][MAXN],dp[MAXN][MAXN];int main(){ int t; scanf("%d",&t); while (t--){ scanf("%d%d%*c",&n,&m); memset(G,1,sizeof(G)); memset(dp,0,sizeof(dp)); for (int i = 1; i <= n; i++){ int tmp; scanf("%d",&tmp); gets(str); int len = strlen(str); int cur = 0; for (int j = 0; j <= len; j++) if (isdigit(str[j])) cur = cur * 10 + str[j] - '0'; else G[tmp][cur] = 0,cur = 0; } dp[1][1] = 1; G[1][1] = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (G[i][j]) dp[i][j] = dp[i-1][j] + dp[i][j-1]; printf("%d\n",dp[n][m]); if (t) printf("\n"); } return 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(记忆化搜索)
- 找不到本地连接
- 如何在eclipse中运行launcher4.2代码(修改包名)
- jquery练习(一)
- webRTC-实时流媒体的福音
- redis--2--redis的使用
- UVA - 825 Walking on the Safe Side
- Java 面向对象 第二部分(继承)
- POJ3318【随机化算法挺有意思】
- 线程池技术个人理解以及c语言的简单实现
- tomcat运行startup.bat运行就关闭了
- LeetCode | Merge k Sorted Lists
- 红蓝军对抗
- Java 面向对象 第三部分(多态)
- Windows Server 2012正式版RDS系列⑿