经典的最长公共子序列问题。
要注意的是题目中的输入会包含空格的情况,所以要用gets实现输入。
代码如下:
#include
#include
#include
using namespace std;
int dp[1100][1100];
int main()
{
    char str1[1100],str2[1100];
    int i,j;
    whi...
                            
                            
                                分类:
其他好文   时间:
2014-12-02 19:17:00   
                                阅读次数:
227
                             
                    
                        
                            
                            
                                Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from th...
                            
                            
                                分类:
其他好文   时间:
2014-11-26 13:37:24   
                                阅读次数:
123
                             
                    
                        
                            
                            
                                三人行,必有我师也。择其善者而从之,其不善者而改之。 
本讲内容:CharSequence类型
一、CharSequence类型是一个接口,代表的是一个有序字符集合,这个接口包含的方法有:charAt(int index),toString(),length(),subSequence(int start,int end).   注意:对于一个抽象类或者是接口类,不能使用n...
                            
                            
                                分类:
移动开发   时间:
2014-11-24 15:27:41   
                                阅读次数:
208
                             
                    
                        
                            
                            
                                Dynamic ProgrammingGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is f...
                            
                            
                                分类:
其他好文   时间:
2014-11-24 09:52:39   
                                阅读次数:
131
                             
                    
                        
                            
                            
                                Problem EDistinct SubsequencesInput:standard inputOutput:standard outputA subsequence of a given sequence is just the given sequence with some element...
                            
                            
                                分类:
其他好文   时间:
2014-11-19 07:05:32   
                                阅读次数:
224
                             
                    
                        
                            
                            
                                Longest Ordered Subsequence
Time Limit: 2000MS
 
Memory Limit: 65536K
Total Submissions: 34454
 
Accepted: 15135
Description
A numeric sequence of ai is ordered if a1 a2 ...
                            
                            
                                分类:
其他好文   时间:
2014-11-16 18:41:55   
                                阅读次数:
202
                             
                    
                        
                            
                            
                                Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)...
                            
                            
                                分类:
其他好文   时间:
2014-11-14 12:40:18   
                                阅读次数:
111
                             
                    
                        
                            
                            
                                题目意思:
http://poj.org/problem?id=1458
给出两个字符串,求出这两个字符串的最长子序列的长度,最长子序列的定义如下:
Given a sequence X =  another sequence Z =  is a subsequence of X if there exists a strictly increasing sequence  of ind...
                            
                            
                                分类:
其他好文   时间:
2014-11-08 23:39:50   
                                阅读次数:
296
                             
                    
                        
                            
                            
                                题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159解题思路:任意先给出两个字符串 abcfbc abfcab,用dp[i][j]来记录当前最长的子序列,则如果有x[i]与y[j]相等的话,则相当于公共子序列的长度在dp[i-1][j-1]上增加1,...
                            
                            
                                分类:
其他好文   时间:
2014-11-08 00:52:18   
                                阅读次数:
312
                             
                    
                        
                            
                            
                                Problem Description
In computer science, the longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence's elements are in sorted order, lowest to hig...
                            
                            
                                分类:
其他好文   时间:
2014-11-06 21:57:19   
                                阅读次数:
187