poj 1080:Human Gene Functions
来源:互联网 发布:大金的淘宝店 编辑:程序博客网 时间:2024/06/05 20:29
解题思路:
(1)打表
(2)动态规划边界状态
(3)动态规划状态转移
#include<iostream>#include<cstring>using namespace std;int main(){int v['T'+1]['T'+1];v['A']['A'] = 5;v['C']['C'] = 5;v['G']['G'] = 5;v['T']['T'] = 5;v['A']['C'] = v['C']['A'] = -1;v['A']['G'] = v['G']['A'] = -2;v['A']['T'] = v['T']['A'] = -1;v['A']['-'] = v['-']['A'] = -3;v['C']['G'] = v['G']['C'] = -3;v['C']['T'] = v['T']['C'] = -2;v['C']['-'] = v['-']['C'] = -4;v['G']['T'] = v['T']['G'] = -2;v['G']['-'] = v['-']['G'] = -2;v['T']['-'] = v['-']['T'] = -1;v['-']['-'] = -9999;int m;cin>>m;while(m--){char a[110],b[110];int lena=0,lenb=0;cin>>lena;cin>>a;cin>>lenb;cin>>b;int dp[110][110];dp[0][0]=0;for(int i=1;i<=lena;i++)dp[0][i] = v['-'][a[i-1]] + dp[0][i-1];for(int i=1;i<=lenb;i++)dp[i][0] = v['-'][b[i-1]] + dp[i-1][0];for(int i=1;i<=lenb;i++){for(int j=1;j<=lena;j++){int p = dp[i-1][j] + v['-'][b[i-1]];int q = dp[i][j-1] + v['-'][a[j-1]];int r = dp[i-1][j-1] + v[b[i-1]][a[j-1]];int t = max(p,q);t = max(t,r);dp[i][j] = t;} } cout<<dp[lenb][lena]<<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
- Android支付接入(三):电信爱游戏支付
- Rotating Sentences
- 股市基础知识、股票的种类
- Android支付接入(四):联通VAC计费
- 数据结构之基本排序算法
- poj 1080:Human Gene Functions
- 图像处理软件 Qt creator + opencv
- [leetcode]N-Queens
- 如何替Makefile加上build code的總時間長短
- mybatis返回HashMap<Long,List<自定义类>>
- Android支付接入(五):机锋网
- Android中measure过程、WRAP_CONTENT详解以及xml布局文件解析流程浅析(下)
- MATLAB学习(3)
- 黑马程序员_网络编程(1)