公共子串
来源:互联网 发布:银天下太极线指标源码 编辑:程序博客网 时间:2024/06/08 17:03
公共子串
Time Limit:1000MS Memory Limit:65536KTotal Submit:196 Accepted:111
Time Limit:1000MS Memory Limit:65536KTotal Submit:196 Accepted:111
Description
设有A、B两个字符串,找出A、B共同子串,每个字符串无相同字符,可以不连续,但顺序不能颠倒。
Input
第一行字符串A 第二行字符串B
Output
最长公共子串的长度.
Sample Input
abcfbcabfcabSample Output
4Source
elba
· Var· s1,s2:string;· i,j,best,p,q,r:longint;· a:array[0..300,0..300] of longint;· begin· read(s1); readln; read(s2);· for i:=1 to length(s1) do· for j:=1 to length(s2) do begin· if s1[i]=s2[j] then· begin· best:=0;p:=a[i-1,j-1]+1; q:=a[i,j-1];
r:=a[i-1,j];
if p>q then
best:=p
else best:=q;
if r>best then
best:=r; a[i,j]:=best;
end else
begin
best:=0; p:=a[i,j-1]; q:=a[i-1,j]
if p>q then best:=p
else best:=q; a[i,j]:=best; end; end; Writeln(a[length(s1),length(s2)]); end.
0 0
- 最长公共子串
- 最长公共子串
- 最大公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- 最长公共子串
- SVNkit
- C++实现鼠标控制 封装常见的模拟鼠标、键盘的操作函数
- C中的预编译宏定义
- github与团队的开发者github保存同步
- 三、Sybase创建数据库示例
- 公共子串
- 使用AIDL方式实现播放音乐的案例.txt
- leetcode 453. Minimum Moves to Equal Array Elements
- Python实战(四)——Python 数据分析
- 教育孩子幻想系列-品质排行榜
- 1004. Counting Leaves (30) 树的遍历 DFS BFS
- AI火爆,但你知道人工智能、机器学习和深度学习有何不同?
- 蓝桥杯历届试题——带分数(dfs+全排列)
- Android之反编译APK