UVA 10066 - The Twin Towers(最长公共子序)
2012-07-20 15:27
459 查看
题目链接
题目 都没看,直接看样例,直接拍代码,1Y。
题目 都没看,直接看样例,直接拍代码,1Y。
#include <stdio.h> #include <string.h> int p[101][101]; int str1[101],str2[101]; int main() { int i,j,n,m,num = 0; while(scanf("%d%d",&n,&m)!=EOF) { if(!n && !m)break; num ++; memset(p,0,sizeof(p)); for(i = 0; i <= n-1; i ++) scanf("%d",&str1[i]); for(i = 0; i <= m-1; i ++) scanf("%d",&str2[i]); for(i = 1; i <= n; i ++) for(j = 1; j <= m; j ++) { if(str1[i-1] == str2[j-1]) { p[i][j] = p[i-1][j-1]+1; } else if(p[i][j-1] > p[i-1][j]) { p[i][j] = p[i][j-1]; } else { p[i][j] = p[i-1][j]; } } printf("Twin Towers #%d\nNumber of Tiles : %d\n",num,p [m]); printf("\n"); } return 0; }
相关文章推荐
- UVa 10192 - Vacation & UVa 10066 The Twin Towers ( LCS 最长公共子串)
- UVa 10192 - Vacation & UVa 10066 The Twin Towers ( LCS 最长公共子串)
- 【UVA】10066-The Twin Towers(最长公共子串问题)
- uva 10066 The Twin Towers (最长公共子)
- UVA 10066 The Twin Towers(LCS)
- UVA 10066 The Twin Towers 双塔 LCS,dp
- UVa 10066 The Twin Towers(最长公共子序列)
- UVA 10405 - Longest Common Subsequence(最长公共子序)
- UVA 10066 -The Twin Towers(最长公共子序列)
- uva 10066 - The Twin Towers(LCS)
- uva 10066 The Twin Towers (最长公共子序列)
- UVA 10066 The Twin Towers
- UVa 10066 - The Twin Towers(LCS水题)
- uva 10066 The Twin Towers(动态规划:LCS)
- UVA - 10066 The Twin Towers(LCS最长公共子序列)
- UVa 10066 - The Twin Towers(LCS水题)
- uva10066 - The Twin Towers(LCS)
- 【解题报告】uva10066_The Twin Towers(双塔, dp, LCS)
- uva10066 - The Twin Towers(dp,lcs)
- The Twin Towers - UVa 10066 最长公共子序列