poj 1080 Human Gene Functions_简单dp
来源:互联网 发布:开一个淘宝店要多少钱 编辑:程序博客网 时间:2024/05/07 17:58
题目链接
题意:给你两个串,再给你一个表,按那个表求两串最大值
思路:
dp[i][j]=max(dp[i-1][j-1]+map[a[i-1]][b[j-1]],dp[i-1][j]+map[a[i-1]]['-'],dp[i][j-1]+map['-'][b[j-1]]);
#include <iostream>#include<cstdio>#include<cstring>using namespace std;#define MAXN 110char a[MAXN],b[MAXN];int u[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,10}};int dp[MAXN][MAXN];int max(int a,int b,int c){a=a>b?a:b;return a>c?a:c;}int sv(char tmp){switch(tmp){case 'A':return 0;break;case 'C':return 1;break;case 'G':return 2;break;case 'T':return 3;break;case '-':return 4;break;}return 5;}int main(int argc, char** argv) {int t,i,j,lena,lenb;scanf("%d",&t);while(t--){scanf("%d %s",&lena,a);scanf("%d %s",&lenb,b);memset(dp,0,sizeof(dp));for(i=1;i<=lena;i++)dp[i][0]=dp[i-1][0]+u[sv('-')][sv(a[i-1])];for(i=1;i<=lenb;i++)dp[0][i]=dp[0][i-1]+u[sv(b[i-1])][sv('-')];for(i=1;i<=lena;i++)for(j=1;j<=lenb;j++)dp[i][j]=max(dp[i-1][j-1]+u[sv(b[j-1])][sv(a[i-1])],dp[i][j-1]+u[sv(b[j-1])][sv('-')],dp[i-1][j]+u[sv('-')][sv(a[i-1])]);printf("%d\n",dp[lena][lenb]);}return 0;}
0 0
- poj 1080 Human Gene Functions_简单dp
- poj 1080 Human Gene Functions 算简单DP
- POJ 1080 Human Gene Functions DP(LCS)
- POJ 1080 Human Gene Functions DP
- dp poj 1080 Human Gene Functions
- POJ 1080 Human Gene Functions DP
- poj 1080 Human Gene Functions(dp)
- poj 1080 Human Gene Functions DP
- POJ 1080-Human Gene Functions(DP)
- POJ 1080-Human Gene Functions(dp)
- POJ 1080 Human Gene Functions(DP)
- POJ 1080 Human Gene Functions(DP)
- POJ 1080 Human Gene Functions dp
- POJ 1080 Human Gene Functions(DP LCS)
- poj 1080 Human Gene Functions DP
- poj--1080 Human Gene Functions(dp)
- poj 1080 Human Gene Functions(dp)
- POJ 1080 Human Gene Functions(DP:LCS)
- 基于关联矩阵的聚类融合算法——Voting-K-Means算法
- LeetCode | Reverse Words in a String
- IOS 断点续下,上传
- 搜索二叉树的操作
- QT4 环境搭建
- poj 1080 Human Gene Functions_简单dp
- POJ 1185 (状态压缩DP)
- 接口中的方法
- 数据挖掘学习笔记(二)
- Oracle数据字典
- leetcode-Valid Number
- 复数类
- Java第一课之输出Hello world
- 每日博客之六:ZigZag Conversion