1. 程式人生 > >hdu 1159 Common Subsequence 【LCS 基礎入門】

hdu 1159 Common Subsequence 【LCS 基礎入門】

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence <i1, i2, ..., ik> of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = <a, b, f, c> is a subsequence of X = <a, b, c, f, b, c> with index sequence <1, 2, 4, 6>. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y. 
The program input is from a text file. Each data set in the file contains two strings representing the given sequences. The sequences are separated by any number of white spaces. The input data are correct. For each set of data the program prints on the standard output the length of the maximum-length common subsequence from the beginning of a separate line. 

相關推薦

hdu 1159 Common Subsequence LCS 基礎入門

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another

HDU 1159.Common Subsequence動態規劃DP3月8

Common Subsequence Problem Description A subsequence of a given sequence is the given sequence with some elements (possible none) lef

HDU 1159 Common SubsequenceLCS

當s1[s]=s2[t]時,在公共子串末尾加上s1[s] 當s1[s]!=s2[t]時,s1當前長度減1與s2比;s2當前長度減1與s1比 if (s1[s] == s2[t]) { dp[s+1][t+1] = dp[s][t] + 1;

hdu-1159 Common Subsequence (dp中的lcs問題)

contain asi dice spa ... con ive min iss Common Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O

hdu-1159 Common Subsequence

program ... clas mission ems 字符 mem example div 題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=1159 題目類型: 最大公共子串 題意概括: 給出兩個字符串,求這兩個

hdu 1159 Common Subsequence

== str printf clu DC max size c++ style hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh #include <bits/stdc++.h> using namespace std; i

題解報告:hdu 1159 Common Subsequence

com span add letter 子序列 rom har 公共子序列 using 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Problem Description 給定序列的子序列是給定的序列,其中有一些元

HDU-1159-Common Subsequence

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > an

AOJ_ALDS1_10_C Longest Common SubsequenceLCS+DP

Longest Common Subsequence Aizu - ALDS1_10_C For given two sequences X and Y, a sequence Z is a common subsequence of X and Y if Z is a subsequence of bot

UVA10405 Longest Common SubsequenceLCS+DP

Given two sequences of characters, print the length of the longest common subsequence of both sequences.     Sequence 1:   

HDU 1159 Common Subsequence(最長公共子序列)

大概題意:給出兩個字串s1,s2,求他們的最長公共子序列長度... 大概算是模板題? #include<cstdio> #include<cstring> #include<algorithm> #include<iostream&

HDU——1159 Common Subsequence(DP 最長公共子序列)

Problem Description   A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a

Flask Web開發基礎入門

Flask框架是Python開發的一個基於Werkzeug和Jinja 2的web開發微框架,它的優勢就是極其簡潔,但又非常靈活,而且容易學習和應用。因此Flask框架是Python新手快速開始web開發最好的選擇,此外,使用Flask框架的另一個好處在於你可以非常輕鬆地將基於Pytho

MFC基礎入門OpenCV人臉檢測與馬賽克

這是OpenCV的程式碼,在這基礎上加了馬賽克。 void CFaceDetectionDlg::detect_and_draw( IplImage* img ) { //static CvScalar colors[] = //{ // {{0,

HDU1159 Common Subsequence(DP、最長公共子序列)

【HDU】1159 Common Subsequence (DP、最長公共子序列) 題目內容 Problem Description A subsequence of a given sequence is the given sequence

hdoj1159:Common Subsequence(dp基礎題-最長公共子序列LCS

目錄 Common Subsequence 題目解釋: 解題思路: ac程式碼: Common Subsequence Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 6553

Advanced Fruits HDU杭電1503LCS的保存

style pro cte rac data- sequence return arch its Problem Description The company "21st Century Fruits" has specialized

HDU 2089 不要62數位DP入門

pan eps ava con 所有 數據 strong mon sub 不要62 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi

Hdoj 1159.Common Subsequence 題解

bit hit pan ... represent 否則 pro example ber Problem Description A subsequence of a given sequence is the given sequence with some elemen

三分入門HDU - 4717 Q - The Moving Points

Q - The Moving Points  HDU - 4717 There are N points in total. Every point moves in certain direction and certain speed. We want to know a