Common Subsequence 1159 hdu
动态规划的入门级别吧,加油继续努力。
#include<stdio.h>
#include<string.h>
int max(int a,int b)
{if(a>b) return a;return b;
}
int main()
{char str1[500];char str2[500];while(scanf("%s%s",str1+1,str2+1)!=EOF){int len1,len2;len1=strlen(str1+1);len2=strlen(str2+1);int c[500][500]={0};for(int i=1;i<=len1;i++){for(int j=1;j<=len2;j++){if(str1[i]==str2[j])c[i][j]=c[i-1][j-1]+1;else c[i][j]=max(c[i-1][j],c[i][j-1]);}}printf("%d\n",c[len1][len2]);} return 0;
}
Common Subsequence 1159 hdu相关推荐
- HDU 1159.Common Subsequence【动态规划DP】
Problem Description A subsequence of a given sequence is the given sequence with some elements (poss ...
- HDU 1159 Common Subsequence 动态规划
2017-08-06 15:41:04 writer:pprp 刚开始学dp,集训的讲的很难,但是还是得自己看,从简单到难,慢慢来(如果哪里有错误欢迎各位大佬指正) 题意如下: 给两个字符串,找到其中 ...
- HD 1159 Common Subsequence (最长公共子序列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Problem Description A subsequence of a given seq ...
- 动态规划—最长公共子序列问题 HDU-1159 Common Subsequence
动态规划-最长公共子序列问题 Common Subsequence [ HDU - 1159 ] A subsequence of a given sequence is the given sequ ...
- C++longest common subsequence最长公共子序列的实现(附完整源码)
C++longest common subsequence最长公共子序列 longest common subsequence最长公共子序列的完整源码(定义,实现,main函数测试) longest ...
- Common Subsequence
原题及翻译 A subsequence of a given sequence is the given sequence with some elements (possible none) lef ...
- 【算法导论学习-29】动态规划经典问题02:最长公共子序列问题(Longest common subsequence,LCS)...
2019独角兽企业重金招聘Python工程师标准>>> 问题描述:序列X={x1,x2,-,xn},Y={y1,y2,-,yn},当Z={z1,z2-,zn}是X的严格递增下标顺序( ...
- UVA10405 Longest Common Subsequence【LCS+DP】
Given two sequences of characters, print the length of the longest common subsequence of both sequen ...
- CF346B Lucky Common Subsequence 题解
CF346B Lucky Common Subsequence 题解 题目链接:CF346B Lucky Common Subsequence 题意:通过删除一个字符串中的某些元素而不改变其余元素的顺 ...
最新文章
- 区块链最积极的布局者:国内5大银行已将“区块链”应用到5大场景当中
- base64 数据处理
- getContext(),getApplicationContext(),getBaseContext()和“ this”之间的区别
- python【力扣LeetCode算法题库】58-最后一个单词的长度
- Excel简单读写操作
- 解禁策略组、注册表、各种应用程序、控制面板、运行、USB
- Android 手电筒源码
- 安装keras and theano于google colab上
- python 自定义函数和循环_Python循环语句——对for循环和while循环应用自定义函数公式的实践,套用,练习...
- C++实现简单选择排序
- ZOJ - 4122 Triangle City(最短路+欧拉通路+思维)
- 定向输出命令_网络工程师之linux重定向命令和管道命令详解
- Linux - 命令
- 几种常见软件过程模型的比较
- linux 修改 java 内存_Linux 和 Windows修改Java虚拟机内存大小
- 周志华《Machine Learning》 学习笔记系列(1)--绪论
- PHP正则表达式实例汇总
- zeppelin配置hive教程
- 计算机显示10的负次方,我输入10的9次方在EXCEL里,为什么总变成日期了?怎么办/excel10的负次方怎么打...
- amd apu战略_添加内存如何显着提高AMD APU的游戏性能?