POJ---1080-Human Gene Functions
来源:互联网 发布:ui切图软件 编辑:程序博客网 时间:2024/06/04 19:23
AC CODE:
#include <iostream>#include <cstring>#include <cmath>#include <cstdio>#include <algorithm>using namespace std;/// 0 A C G Tint score[6][6]={{0,-3,-4,-2,-1}, {-3,5,-1,-2,-1},{-4,-1,5,-3,-2},{-2,-2,-3,5,-2},{-1,-1,-2,-2,5}};int dp[101][101];int a[101],b[101];int lena,lenb;int mmax(int a,int b,int c){ return max(a,max(b,c));}int main(){ int n; int i,j; char str; cin>>n; while(n--) { cin>>lena; for(i=0; i<lena; ++i) { cin>>str; if(str=='A')a[i]=1; else if(str=='C')a[i]=2; else if(str=='G')a[i]=3; else if(str=='T')a[i]=4; else a[i]=0; } a[i]=0; cin>>lenb; for(i=0; i<lenb; ++i) { cin>>str; if(str=='A')b[i]=1; else if(str=='C')b[i]=2; else if(str=='G')b[i]=3; else if(str=='T')b[i]=4; else b[i]=0; } b[i]=0; dp[0][0]=0; //dp[1][0]=score[ a[0] ][0]; // dp[0][1]=score[0][ b[0] ]; for(i=1; i<=lena; ++i) { dp[i][0]=dp[i-1][0]+score[0][ a[i-1] ]; } for(j=1; j<=lenb; ++j) { dp[0][j]=dp[0][j-1]+score[0][ b[j-1] ]; } for(i=1; i<=lena; ++i) for(j=1; j<=lenb; ++j) { dp[i][j]=mmax(dp[i-1][j]+score[0][ a[i-1] ] , dp[i][j-1]+score[0][ b[j-1] ] , dp[i-1][j-1]+score[a[i-1] ][ b[j-1] ]); } cout<<dp[lena][lenb]<<endl; } return 0;}
0 0
- POJ 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- poj 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- Poj 1080 Human Gene Functions
- poj 1080 Human Gene Functions
- poj 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- poj 1080 human gene functions
- POJ 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- POJ-1080-Human Gene Functions
- POJ 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- poj 1080 Human Gene Functions
- poj 1080 Human Gene Functions
- POJ 1080 Human Gene Functions
- HDU 2448 — Mining Station on the Sea 最优匹配+Floyd
- 11882 - Biggest Number(DFS + 剪枝)
- 字符串工具类
- char/byte/short类型的加法和类型转换问题
- 修改Android studio背景主题
- POJ---1080-Human Gene Functions
- doget与dopost
- Android eclipse 提示java代码 快捷键
- 【基础练习】【背包DP】codevs1068 乌龟棋题解
- hibernate 4.2.0错误
- LeetCode 题解(165): Combinations
- 九度 Online Judge 算法 刷题 题目1031:xxx定律
- IE8中按下回车键之后自动出现提交
- hdu 5364 Distribution money