当前位置:网站首页>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;
}
边栏推荐
- YOLOv3 Pytorch代码及原理分析(二):网络结构和 Loss 计算
- highcharts设置柱状图宽度、渐变、圆角、柱子上方数据
- Activate function formulas, derivatives, image notes
- Gmail: how do I recall an outgoing message?
- [image denoising] impulse noise image denoising based on absolute difference median filter, weighted median filter and improved weighted median filter with matlab code attached
- Automated test requirements analysis
- collect. stream(). Use of the collect() method
- 构建Web应用程序
- Golang学习笔记—基础篇
- 【图像分割】基于马尔可夫随机场实现图像分割附matlab代码
猜你喜欢
【求助】請問如何讓微信公眾號文章在外部瀏覽器中打開後還能顯示下方的精選留言?

Yolov3 pytoch code and principle analysis (II): network structure and loss calculation

AHB2APB_bridge 设计

AHB2Standard_handshake_bridge 设计

AHB_Bus_Matrix_3x3 设计

Record the phpstudy configuration php8.0 and php8.1 extension redis

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

This article introduces you to the infrastructure of sofaregistry

Key contents that wwdc22 developers need to pay attention to

MOS transistor 24n50 parameters of asemi, 24n50 package, 24n50 size
随机推荐
Qubicle notes: Hello voxel
YOLOv3 Pytorch代码及原理分析(一):跑通代码
pstack和dmesg
2022 the latest software testing classic summarized by major manufacturers. After reading it, I'm not afraid I won't get an offer
SLAM APP
Building web applications
On Workflow selection
Review of software testing technology
【Bug解决】UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.
This article introduces you to the infrastructure of sofaregistry
使用canvas给页面添加文字水印
图床:PicGo+腾讯云+typora
30讲 线性代数第二讲 矩阵
What is the workflow of dry goods MapReduce?
01. Telecommunications_ Field business experience
Use Mysql to determine the day of the week
Yolov3 pytoch code and principle analysis (II): network structure and loss calculation
Pymysql uses cursor operation database method to encapsulate!!!
Raki's notes on reading paper: learning fast, learning slow: a general continuous learning method
Highcharts sets the histogram width, gradient, fillet, and data above the column