当前位置:网站首页>POJ 1458 longest common subsequence (dynamic planning exercise)
POJ 1458 longest common subsequence (dynamic planning exercise)
2022-06-11 19:33:00 【*c.】
Catalog
Dynamic planning details
Example POJ 1458
1458 -- Common Subsequencehttp://poj.org/problem?id=1458

#include<iostream>
#include<cstring>
using namespace std;
#define MAX 1000
const int N=1e7+10;
char a[1000],b[1000];
int maxlen[MAX][MAX];
int main()
{
int i,j;
while(cin>>a>>b)
{
int l1=strlen(a);
int l2=strlen(b);
for(i=0,j=0;j<=l2;j++)
{
maxlen[i][j]=0;
}
for(i=0,j=0;i<=l1;i++)
{
maxlen[i][j]=0;
}
for(i=1;i<=l1;i++)
{
for(j=1;j<=l2;j++)
{
if(a[i-1]==b[j-1])
maxlen[i][j]=maxlen[i-1][j-1]+1;
else
maxlen[i][j]=max(maxlen[i-1][j],maxlen[i][j-1]);
}
}
cout<<maxlen[l1][l2]<<endl;
}
return 0;
}
边栏推荐
- Anaconda installation, jupyter notebook default startup path modification and nbextensions plug-in installation
- Yolov3 pytoch code and principle analysis (I): runthrough code
- Bottomsheetdialog usage details, setting fillet, fixed height, default full screen, etc
- Common - name of conference room
- 【信号去噪】基于非线性滤波器实现语音自适应去噪附matlab代码
- [C language questions -- 10 simple questions for leetcode]
- postman配置中文
- AHB2APB_bridge 设计
- Questions and requirements of the "high rise building structure" assignment of Dayong in the 21st autumn [standard answer]
- CMU 15-445 database course lesson 5 text version - buffer pool
猜你喜欢

Qubicle notes: Hello voxel

CMU 15 - 445 cours de base de données Leçon 5 version texte - Pool tampon

AHB2APB_bridge 设计

CMU 15-445 database course lesson 5 text version - buffer pool

Anaconda安装、Jupyter Notebook默认启动路径修改及Nbextensions插件安装

Highcharts sets the histogram width, gradient, fillet, and data above the column

NR LDPC punched
CMU 15-445 database course lesson 5 text version - buffer pool

Lecture 30 linear algebra Lecture 2 Matrix

【视频去噪】基于SALT实现视频去噪附Matlab代码
随机推荐
[Lao Wang's fallacy of brain science] Why do blind people "seem" to be more "sensitive" than normal people?
cocan yocto buildroot
无监督图像分类《SCAN:Learning to Classify Images without》代码分析笔记(1):simclr
司空见惯 - 会议室名称
Offline assignment template and requirements of the course design of real estate development and operation in the 21st autumn of Dagong [standard answer]
Introduction to ieda bottom menu
Operator new and placement new
Use canvas to add text watermark to the page
Chrome tips - browser web page setting coding, solving the problem of web page garbled code, obtaining the latest version of charset plug-in, UTF-8 coding setting
【高精度】X进制整数加法
Introduction to go language (VI) -- loop statement
Golang学习笔记—基础篇
collect. stream(). Use of the collect() method
Introduction to typescript
Raki's notes on reading paper: learning fast, learning slow: a general continuous learning method
[image denoising] impulse noise image denoising based on absolute difference median filter, weighted median filter and improved weighted median filter with matlab code attached
[video denoising] video denoising based on salt with matlab code
What is the workflow of dry goods MapReduce?
About my experience of "binary deployment kubernetes cluster"
CMU 15-445 database course lesson 5 text version - buffer pool