题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1027

http://poj.org/problem?id=1080

解题报告:

1、类似于LCS

2、gene[i][j]表示str1[i-1]和str2[j-1]的分值串没有,则应该扣分

3、递推公式

temp1=gene[i-1][j-1]+score[_map[str1[i-1]]][_map[str2[j-1]]];

temp2=gene[i-1][j]+score[_map[str1[i-1]]][4];

temp3=gene[i][j-1]+score[4][_map[str2[j-1]]];

gene[i][j]=max(temp1,max(temp2,temp3));

4、在初始化边界条件时,认为一个字符串为空,则要扣分

#include <cstdio>
#include <algorithm>
#include <map>
#define NUM 105 using namespace std; int score[][]= {{,-,-,-,-},{-,,-,-,-},{-,-,,-,-},{-,-,-,,-},{-,-,-,-,}}; map<char,int> _map; char str1[NUM],str2[NUM];
int len1,len2; int gene[NUM][NUM];///gene[i][j]表示基因子串str1[i-1]和str2[j-1]的分值. int main()
{
_map['A']=,_map['C']=,_map['G']=,_map['T']=,_map['-']=;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%s",&len1,str1);
scanf("%d%s",&len2,str2);
///初始化边界条件
gene[][]=;
for(int i=; i<=len1; i++)
gene[i][]=gene[i-][]+score[_map[str1[i-]]][];
for(int i=; i<=len2; i++)
gene[][i]=gene[][i-]+score[][_map[str2[i-]]];
int m1,m2,m3;
for(int i=; i<=len1; i++)
{
for(int j=; j<=len2; j++)
{
m1=gene[i-][j]+score[_map[str1[i-]]][];///str1取i-1个字符,str2取'-';
m2=gene[i][j-]+score[][_map[str2[j-]]];///str1取'-',str2取j-1个字符;
m3=gene[i-][j-]+score[_map[str1[i-]]][_map[str2[j-]]];///str1取i-1个字符,str2取j-1个字符
gene[i][j]=max(m1,max(m2,m3));
}
}
printf("%d\n",gene[len1][len2]);
}
return ;
}

动态规划(DP),Human Gene Functions的更多相关文章

  1. POJ 1080:Human Gene Functions LCS经典DP

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18007   Accepted:  ...

  2. poj 1080 Human Gene Functions(lcs,较难)

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19573   Accepted:  ...

  3. Human Gene Functions

    Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 1004 ...

  4. hdu1080 Human Gene Functions() 2016-05-24 14:43 65人阅读 评论(0) 收藏

    Human Gene Functions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  5. poj 1080 ——Human Gene Functions——————【最长公共子序列变型题】

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17805   Accepted:  ...

  6. 【POJ 1080】 Human Gene Functions

    [POJ 1080] Human Gene Functions 相似于最长公共子序列的做法 dp[i][j]表示 str1[i]相应str2[j]时的最大得分 转移方程为 dp[i][j]=max(d ...

  7. POJ 1080 Human Gene Functions -- 动态规划(最长公共子序列)

    题目地址:http://poj.org/problem?id=1080 Description It is well known that a human gene can be considered ...

  8. poj1080 - Human Gene Functions (dp)

    题面 It is well known that a human gene can be considered as a sequence, consisting of four nucleotide ...

  9. 杭电20题 Human Gene Functions

    Problem Description It is well known that a human gene can be considered as a sequence, consisting o ...

  10. 刷题总结——Human Gene Functions(hdu1080)

    题目: Problem Description It is well known that a human gene can be considered as a sequence, consisti ...

随机推荐

  1. oracle 单实例DG(搭建篇一)

    一,介绍 lodding... 二,安装前环境配置 01,依赖包的安装: yum install binutils-* yum install compat-libstdc++-* yum insta ...

  2. python-URL转jpg图片

    问题描述 有图片地址,可以在网页打开 URL:https://bdfile.bluemoon.com.cn/group2/M00/0A/BA/wKg_HlwzY1SAIdXDAAFyo-ZOLKQ39 ...

  3. SQL Server 2008 SQL2012 SQL2014 收缩日志 清空删除大日志文件

    SQL2008 SQL2012 SQL2014 的收缩日志 由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消:(SQL2005)Bac ...

  4. Ubuntu系统里如何正确卸载oracle-j2sdk1.6(图文详解)

    问题来源 因为,我在安装clouder manager5.X的时候,默认是需要oracle-j2sdk1.7. 它4.X时,才是1.6的. 若你还是在用clouder manager4.X版本的话,需 ...

  5. Nginx图片服务器

    最近总项目因为需要显示图片,就使用了Nginx,使用很简单,下面简单介绍一下怎么用 压缩包下载地址,解压即用 http://files.cnblogs.com/files/sanduweiliangx ...

  6. react native 完美解决启动白屏

    先讲下我的RN版本0.58.5 首先安装react-native-splash-screen(目前使用的版本是3.2.0) 项目地址https://github.com/crazycodeboy/re ...

  7. 【转载】BaseDao设计

    BaseDao接口设计 1 import java.util.List; /** * Dao接口,定义Dao基本操作 由BaseDaoImpl实现 * @author wht * @param < ...

  8. struts2====之=======初识struts

    ---恢复内容开始--- 1.什么是web框架? 目前应用得较多的三种服务器瑞页面描写技术就是ASP,JSP和PHP.J S P通过在HTMLJî面 文件中嵌入J a v a脚本代码,从而实现动态网页 ...

  9. javascript12个你必须掌握的技能

    网站建设的时候,作为码农,总喜欢写一些高效且省事的代码,这里,dbestech为你提供关于JavaScript的使用技巧点. 1. 空(null, undefined)验证 当我们创建了一个新的变量, ...

  10. js实现手风琴效果

    之前在慕课网上有练习手风琴效果,但是老师使用jquery简简单单的两三行实现了,今天自己用js练习一下效果 <div id="divbox"> <ul> & ...