栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1027 Human Gene Functions

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1027 Human Gene Functions

#include <iostream>#include <cstdio>#include <string.h>using namespace  std;int value[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 main(){int ncase;scanf("%d",&ncase);int num_a;int num_b;char a;int str[108][2];int i ,k,j;int result[108][108]={0};while (ncase -- ){memset(str,0,sizeof(str));scanf("%d%*c",&num_a);k = 0;for ( i = 0 ; i < num_a;i++){scanf("%c",&a);if( a == 'A') str[i][k] = 0 ;else if( a == 'C') str[i][k]=1;else if( a=='G')str[i][k]=2;else if( a=='T')str[i][k] = 3;else str[i][k] = 4;}getchar();scanf("%d%*c",&num_b);k = 1;for ( i = 0 ; i < num_b;i++){scanf("%c",&a);if( a == 'A') str[i][k] = 0 ;else if( a == 'C') str[i][k]=1;else if( a=='G')str[i][k]=2;else if( a=='T')str[i][k] = 3;else str[i][k] = 4;}getchar();for(i = 0;i<num_a+1;i++){for(j= 0 ; j<num_b+1;j++){result[i][j] = -1000;}}result[0][0] = 0;for(i = 0 ; i < num_a;i++){for(j = 0 ; j<num_b;j++){if(i+1 <= num_a && result[i][j]  + value[ str[i][0] ][ 4 ] > result[ i + 1 ][j]) result[ i + 1 ][j] = result[i][j]  + value[ str[i][0] ][ 4 ];if( j+1 <= num_b && result[i][j]  + value[4][ str[j][1] ]  > result[i][j+1]) result[i][j+1] = result[i][j]  + value[4][ str[j][1] ] ;if( j+1 <= num_b && i+1 <= num_a && result[i][j] + value[str[i][0] ] [str[j][1]]  > result[i+1][j+1])result[i+1][j+1] = result[i][j] + value[str[i][0] ] [str[j][1]] ;}}printf("%dn",result[num_a][num_b]);}return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380035.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号