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

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std; const int INF=<<;
int score[][];
void init()
{
score['A']['C']=score['C']['A']=-;
score['A']['G']=score['G']['A']=-;
score['A']['T']=score['T']['A']=-;
score['A']['-']=score['-']['A']=-;
score['C']['G']=score['G']['C']=-;
score['C']['T']=score['T']['C']=-;
score['C']['-']=score['-']['C']=-;
score['G']['T']=score['T']['G']=-;
score['G']['-']=score['-']['G']=-;
score['T']['-']=score['-']['T']=-;
}
int main()
{
int t,dp[][];
scanf("%d",&t);
init();
while(t--)
{
int len1,len2;
char s1[],s2[];
scanf("%d %s",&len1,s1+);
scanf("%d %s",&len2,s2+);
for (int i = ; i <= len1; i++)
{
for (int j = ; j <= len2; j++)
{
dp[i][j] = -INF;
}
}
dp[][] = ;
for (int i = ; i <= len2; i++)
{
dp[][i] = dp[][i-]+score[s2[i]]['-'];
}
for (int j = ; j <= len1; j++)
{
dp[j][] = dp[j-][]+score[s1[j]]['-'];
}
for (int i = ; i <= len1; i++)
{
for (int j = ; j <= len2; j++)
{
if (s1[i]!=s2[j])
{
dp[i][j] = max(dp[i][j],dp[i-][j-]+score[s1[i]][s2[j]]);
dp[i][j] = max(dp[i][j],
max(dp[i-][j]+score[s1[i]]['-'],dp[i][j-]+score['-'][s2[j]]));
}
else
{
dp[i][j] = max(dp[i][j],dp[i-][j-]+);
}
}
}
printf("%d\n",dp[len1][len2]);
}
return ;
}

Human Gene Functions(dp)的更多相关文章

  1. poj1080 - Human Gene Functions (dp)

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

  2. poj 1080 Human Gene Functions(dp)

    题目:http://poj.org/problem?id=1080 题意:比较两个基因序列,测定它们的相似度,将两个基因排成直线,如果需要的话插入空格,使基因的长度相等,然后根据那个表格计算出相似度. ...

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

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

  4. Human Gene Functions

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

  5. poj1080--Human Gene Functions(dp:LCS变形)

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

  6. 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 ...

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

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

  8. 【POJ 1080】 Human Gene Functions

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

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

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

随机推荐

  1. Nrpe 插件安装教程

    Nrpe 插件安装教程  blog地址: http://www.cnblogs.com/caoguo 一.nagios plugins的安装 [root@Nrpe ~]# yum install -y ...

  2. bytes类型和python中编码的转换方法

    一.bytes类型 bytes类型是指一堆字节的集合,在python中以b开头的字符串都是bytes类型.例如: >>> a = "中国" >>> ...

  3. Java基础学习总结(74)——Java常见笔试题及答案汇总

    1. 下面哪些是合法的标识符?(ABE )--标识符 A. $persons B. TwoUsers C. *point D. this E. _endline 2. 下面程序运行的结果是( D )- ...

  4. noip模拟赛 浮游大陆的68号岛

    题目描述 妖精仓库里生活着黄金妖精们,她们过着快乐,却随时准备着迎接死亡的生活. 换用更高尚的说法,是随时准备着为这个无药可救的世界献身. 然而孩子们的生活却总是无忧无虑的,幼体的黄金妖精们过着天真烂 ...

  5. HBase行键的设计

    rowkey是行的主键,而且hbase只能用rowkey范围即scan来查找数据.rowkey是以字典排序的.可以巧妙设计行键,比如想通过电影的评价进行排序,可以把评分rate和电影id组合起来,ra ...

  6. [bzoj1010][HNOI2008]玩具装箱toy_斜率优化dp

    玩具装箱toy bzoj-1010 HNOI-2008 题目大意:P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一 ...

  7. Linxu用户管理(转)

    说明:用户管理的操作涉及root权限,所以以下实例中应该使用sudo或者root用户进行操作. 背景: Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管 ...

  8. pthread2

    下面我们来看看这个demo #include <stdio.h> #include <pthread.h> #include <unistd.h> #include ...

  9. EasyUI 在textbox里面输入数据敲回车后查询和普通在textbox输入数据敲回车的区别

    EasyUI实现回车键触发事件 $('#id').textbox('textbox').keydown(function (e) { if (e.keyCode == 13) { alert('ent ...

  10. php集成环境安装与測试

    一. 软件下载 1. AppServ 2.5.10包括的软件有Apache.Apache Monitor.PHP.MySQL.PHP-Nuke.phpMyAdmin. 2. 下载地址: http:// ...