题解:裸的LCS

/*LCS*/
#include <iostream>
#include <string>
using namespace std;
int f[1000][1000]={0};
int main()
{string a,b;while(cin>>a>>b){int m,n;n=a.length();m=b.length();memset(f,0,sizeof(f));for (int i=0; i<n; i++)for (int j=0; j<m; j++){if (a[i]==b[j]) f[i+1][j+1]=f[i][j]+1;else (f[i][j+1]>f[i+1][j])?f[i+1][j+1]=f[i][j+1]:f[i+1][j+1]=f[i+1][j];}printf("%d\n",f[n][m]);}return 0;
}

转载于:https://www.cnblogs.com/forever97/p/3529167.html

HDU 1159 Common Subsequence相关推荐

  1. HDU 1159.Common Subsequence【动态规划DP】

    Problem Description A subsequence of a given sequence is the given sequence with some elements (poss ...

  2. HDU 1159 Common Subsequence 动态规划

    2017-08-06 15:41:04 writer:pprp 刚开始学dp,集训的讲的很难,但是还是得自己看,从简单到难,慢慢来(如果哪里有错误欢迎各位大佬指正) 题意如下: 给两个字符串,找到其中 ...

  3. hdu 1159 Common Subsequence (dp)

    点击打开链接 题目意思: 简单DP应用.. 给你两个字符串看看有依次有多少字符相同, Dp[i][j]表示str_1的前i个字符与str_2的前J个字符有dp[i][j]个相同的. dp[i][j]= ...

  4. HD 1159 Common Subsequence (最长公共子序列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Problem Description A subsequence of a given seq ...

  5. 动态规划—最长公共子序列问题 HDU-1159 Common Subsequence

    动态规划-最长公共子序列问题 Common Subsequence [ HDU - 1159 ] A subsequence of a given sequence is the given sequ ...

  6. C++longest common subsequence最长公共子序列的实现(附完整源码)

    C++longest common subsequence最长公共子序列 longest common subsequence最长公共子序列的完整源码(定义,实现,main函数测试) longest ...

  7. Common Subsequence

    原题及翻译 A subsequence of a given sequence is the given sequence with some elements (possible none) lef ...

  8. 【算法导论学习-29】动态规划经典问题02:最长公共子序列问题(Longest common subsequence,LCS)...

    2019独角兽企业重金招聘Python工程师标准>>> 问题描述:序列X={x1,x2,-,xn},Y={y1,y2,-,yn},当Z={z1,z2-,zn}是X的严格递增下标顺序( ...

  9. UVA10405 Longest Common Subsequence【LCS+DP】

    Given two sequences of characters, print the length of the longest common subsequence of both sequen ...

最新文章

  1. 让wordpress首页不显示指定分类文章
  2. Cissp-【第3章 安全工程】-2021-2-24(322页-376页)
  3. expdp\impdp及exp\imp
  4. 二叉查找树的C语言实现(一)
  5. Magento 添加后台管理 addColumn
  6. checkbox修改默认样式
  7. 宁采臣 c语言好爽,C语言链表的来源分析
  8. 去掉IE的图片工具条
  9. 佛山高新区构建大数据产业新生态
  10. js 数组 改变长度_使用JS实现链表(1)——单链表
  11. ubuntu不能更新包
  12. sql 替换字段中的部分字符,替换指定字符
  13. 一套简单的进销存管理系统源码
  14. 通过代码创建obj格式的三维模型
  15. UCSC_2bit基因组格式ToFASTA格式
  16. 江苏省等保测评机构项目测评收费价格标准参考
  17. 计算机专业创新创业培养,中职计算机专业学生创新创业能力培养思考
  18. Centos7 -- 用三种方法设置代理服务器上网
  19. 知网CAJ转为PDF下载
  20. 4pin oled字模,oled图片编码生成方法

热门文章

  1. Visual Entity 手册
  2. 实习技术员的基本功(四)
  3. C++ enum 枚举
  4. SQLite 入门教程(二)创建、修改、删除表
  5. KERNELRELEASE
  6. S5 Linux信息显示与搜索文件命令
  7. linux ntp同步日志,Linux使用入门教程之Rsyslog日志管理、NTP和Rsync备份同步
  8. 苹果手机看python文件大小_Python练习题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于iPhone5分辨率的大小...
  9. 智联招聘python岗位_Python爬虫爬取智联招聘职位信息
  10. 零基础学Java编程的三个重点学习内容