题目链接:http://ac.jobdu.com/problem.php?pid=1042

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
// 1042 Coincidence.cpp
// Jobdu
//
// Created by PengFei_Zheng on 24/04/2017.
// Copyright © 2017 PengFei_Zheng. All rights reserved.
// #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#define MAX_SIZE 101 using namespace std; char a[MAX_SIZE];
char b[MAX_SIZE];
int dp[MAX_SIZE][MAX_SIZE]; int main(){
while(scanf("%s%s",a,b)!=EOF){
int lena = (int)strlen(a);
int lenb = (int)strlen(b);
for(int i = ; i <= lena ; i++){
dp[i][] = ;
}
for(int j = ; j <= lenb ; j++){
dp[][j] = ;
}
for(int i = ; i <= lena ; i++){
for(int j = ; j <= lenb ; j++){
if(a[i-]!=b[j-]){
dp[i][j] = max(dp[i-][j],dp[i][j-]);
}
else{
dp[i][j] = dp[i-][j-]+;
}
}
}
printf("%d\n",dp[lena][lenb]);
}
return ;
}
/**************************************************************
Problem: 1042
User: zpfbuaa
Language: C++
Result: Accepted
Time:0 ms
Memory:1560 kb
****************************************************************/

题目1042:Coincidence(最长公共子序列 dp题目)的更多相关文章

  1. LCS最长公共子序列~dp学习~4

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1513 Palindrome Time Limit: 4000/2000 MS (Java/Others ...

  2. POJ 1458 最长公共子序列(dp)

    POJ 1458 最长公共子序列 题目大意:给出两个字符串,求出这样的一 个最长的公共子序列的长度:子序列 中的每个字符都能在两个原串中找到, 而且每个字符的先后顺序和原串中的 先后顺序一致. Sam ...

  3. hdu 1159 Common Subsequence(最长公共子序列 DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Common Subsequence Time Limit: 2000/1000 MS (Jav ...

  4. 【BZOJ2423】[HAOI2010]最长公共子序列 DP

    [BZOJ2423][HAOI2010]最长公共子序列 Description 字符序列的子序列是指从给定字符序列中随意地(不一定连续)去掉若干个字符(可能一个也不去掉)后所形成的字符序列.令给定的字 ...

  5. 38-最长公共子序列(dp)

    最长公共子序列 https://www.nowcoder.com/practice/c996bbb77dd447d681ec6907ccfb488a?tpId=49&&tqId=293 ...

  6. 最长公共子序列 DP

    class Solution: def LCS(self,A,B): if not A or not B: #边界处理 return 0 dp = [[0 for _ in range(len(B)+ ...

  7. bzoj3304[Shoi2005]带限制的最长公共子序列 DP

    题意:给出三个序列,求出前两个的公共子序列,且包含第三个序列,要求长度最长. 这道题目怎么做呢,f[i][j]表示a串1-i,b串1-j的最长,g[i][j]表示a串i-n,b串j-m最长, 那么只需 ...

  8. 洛谷-P1439 【模板】最长公共子序列 (DP,离散化)

    题意:给两个长度为\(n\)的全排列,求他们的LCS 题解:这题给的数据范围到\(10^5\),用\(O(n^2)\)的LCS模板过不了,但由于给的是两个全排列,他们所含的元素都是一样的,所以,我们以 ...

  9. 求最长公共子序列-DP问题

    Longest common subsequence problem The longest common subsequence (LCS) problem is the problem of fi ...

随机推荐

  1. 一款纯HTML+CSS+JS富文本编辑器-handyeditor

    官网:http://he.catfish-cms.com/ 修改版本(修改一些BUG和图片上传服务器 点击下载: handyeditor富文本编辑器.zip): 图片上传接口上传类型: Content ...

  2. CSS z-index优先级

    可以设置div层与层之间的优先级,上下层覆盖优先情况. 当你定义的CSS中有position属性值为absolute.relative或fixed, 用z-index取值方可生效. 如果想要一个小的d ...

  3. linux nginx,php开机启动

    nginx开机启动 1.首先,在linux系统的/etc/init.d/目录下创建nginx文件 vim /etc/init.d/nginx 2.加入脚本 #!/bin/bash # nginx St ...

  4. C语言之Bit-wise Operation和Logical Operation

    首先第一点:十六进制位运算和逻辑运算 都是先转化二进制,后输出结果(十六进制,二或十)Bit-Wise Operations (位运算)包括:& 按位与 | 按位或 ^ 按位异或 ~ 取反 & ...

  5. django test模块

    今天试了试django自带的test模块,断点执行到一下代码中时发现一点儿小问题: def _create_test_db(self, verbosity, autoclobber): "& ...

  6. windows2008 使用nginx 反向代理实现负载均衡解决HTTPS 证书问题

    由于项目需要 负载均衡由NBL 转成nginx 反向代理.考虑都是https模块,所以证书成了个难题. 解决方案: 1.下载openssl(windows 安装包) 2.打开bin/下面的openss ...

  7. LINE 不被封锁的技巧

    什么是封锁? 谈LINE 被封锁之前,我们先来了解一下什么是封锁.LINE 的封锁分为「好友封锁你」与「官方封锁你」二种,有些人将官方封锁讲成「停权」,其实LINE 的停权并不是你的帐号全被封锁,被封 ...

  8. golang程序在windows上,注册为服务

    https://blog.csdn.net/yang8023tao/article/details/53332984

  9. Nexus5 电信3G保留数据和Root升级Android 6.0

    前提: A 备份手机重要数据,安全第一 B 进入twrp recovery 备份EFS,建议最好拷贝到电脑上(如果没有twrp,则需要先刷twrp,具体指令请看下面步骤第10条) C 因为Androi ...

  10. 8 -- 深入使用Spring -- 3...1 Resource实现类ClassPathResource

    8.3.1 Resource实现类------ClassPathResource : 访问类加载路径下的资源的实现类 2.访问类加载路径下的资源 ClassPathResource 用来访问类加载路径 ...