hdu1159-Common Subsequence
系統
1664 0
dp之最長公共子序列
?
// File Name: hdu1159.cpp
// Author: rudolf
// Created Time: 2013年04月25日 星期四 12時12分33秒
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
using namespace std;
const int maxn=1005;
int dp[maxn][maxn];
int main()
{
int len1,len2;
string str1,str2;
while(cin>>str1>>str2)
{
memset(dp,0,sizeof(dp));
for(int i=0;i<str1.length();i++)
for(int j=0;j<str2.length();j++)
{
if(str1[i]==str2[j])
dp[i+1][j+1]=dp[i][j]+1;
else
dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
}
cout<<dp[str1.length()][str2.length()]<<endl;
}
return 0;
}
?
?
hdu1159-Common Subsequence
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元