ACM PKU 1080 Human Gene Functions http://acm.pku.edu.cn/JudgeOnline/problem?id=1080

做了几天的一道题,一步一步向前推进,现在看着都想吐了,什么解题报告我也不想写了,就这样吧!

只有继续加油!!!

#include <iostream>
using namespace std;

char in_st[101];
char in_ed[101];

int gene[5][5] = 
{
5,-1,-2,-1,-3,
   -1,5,-3,-2,-4,
   -2,-3,5,-2,-2,
   -1,-2,-2,5,-1,
   -3,-4,-2,-1,0
};

int change( char c )
{
if( c == 'A' ) return 0;
if( c == 'C' ) return 1;
if( c == 'G' ) return 2;
if( c == 'T' ) return 3;
if( c == '_' ) return 4;
}

int vl( char c1, char c2 )
{
return gene [change(c1)] [change(c2)];
}

int score[101][101];

int main()
{
int N;
cin >> N;
while (N--)
{
   int m , n ,i ,j;
   cin >> m >>in_st;
   cin >> n >>in_ed;
  
   score[0][0] = 0;
   memset(score,0,sizeof(score));
  
   for (i = 1;i <= m;i++)
    score[i][0] = score[i - 1][0] + vl(in_st[i-1], '_' );
  
   for (j = 1;j <= n;j++)
    score[0][j] = score[0][j - 1] + vl('_', in_ed[j-1] );
  
   int temp = 0;
  
   for (i = 1;i <= m;i++)
   {
    for (j = 1;j <= n;j++)
    {
     if (in_st[i-1] == in_ed[j-1])
      score[i][j]= score[i-1][j-1] + 5 ;
     else 
     {
      temp = score[i - 1][j-1] + vl(in_st[i-1], in_ed[j-1]);
     
      if (score[i][j - 1] + vl( '_', in_ed[j-1] ) > temp)
       temp = vl( '_', in_ed[j-1] ) + score[i][j - 1];
     
     
      if (score[i - 1][j] + vl(in_st[i-1], '_' ) > temp)
       temp = vl( in_st[i-1], '_' ) + score[i - 1][j];
      score[i][j]= temp ;   
     }
    }
   }
  
   cout << score[m][n] <<endl;   
}
return 0;
}

转载于:https://www.cnblogs.com/Chinese-Coder-Clarence/articles/2039279.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值