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. Linux 查询PID和端口号

    https://www.cnblogs.com/understander/p/5546458.html

  2. nagios 安装pnp4nagios插件

    Naigos install pnp4nagios 绘图插件 原文地址:http://www.cnblogs.com/caoguo/p/5022230.html [root@Cagios ~]# yu ...

  3. NSOperationQueue和GCD的区别,以及在什么场合下使用

    1> GCD是纯C语言的API .NSOperationQueue是基于GCD的OC的封装. 2> GCD只支持FIFO队列,NSOperationQueue可以方便设置执行顺序,设置最大 ...

  4. PHP 之simple_html_dom实现网页数据采集

    <?php set_time_limit(0); include './simple_html_dom.php'; $url = 'https://price.pcauto.com.cn/pri ...

  5. 《C++ Primer 第5版》第1章

    1.1 一个简单的C++程序 #include <iostream>int main() {    std::cout << "Hello World!" ...

  6. CAD创建一个新的图形文件

    static void linea(void) { AcDbDatabase *pDb = new AcDbDatabase(true, false); AcGePoint3d pickPoint; ...

  7. Opencv学习之路—Opencv下基于HOG特征的KNN算法分类训练

    在计算机视觉研究当中,HOG算法和LBP算法算是基础算法,但是却十分重要.后期很多图像特征提取的算法都是基于HOG和LBP,所以了解和掌握HOG,是学习计算机视觉的前提和基础. HOG算法的原理很多资 ...

  8. 比n大的最小不重复数

    void Calculate(int a) { int pa = a; ; ] = {}; //将pa按位存储到数组b ) { b[count++] = pa%; pa = pa/; } bool f ...

  9. Chat Group gym101775A(逆元,组合数)

    传送门:Chat Group(gym101775A) 题意:一个宿舍中又n个人,最少k(k >= 3)个人就可以建一个讨论组,问最多可以建多少个不同的讨论组. 思路:求组合数的和,因为涉及除法取 ...

  10. Problem 29

    Problem 29 Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 仔细看看以下a与b的组合 22=4, 2 ...