Human Gene Functions(POJ 1080)
来源:互联网 发布:淘宝美工属于什么行业 编辑:程序博客网 时间:2024/06/05 08:12
题解:最长公共子序列
状态转移方程 d[i][j]=max(d[i-1][j-1]+match[s1[i-1]][s2[j-1]],d[i-1][j]+match[s1[i-1]]['-'],d[i][j-1]+match['-'][s2[j-1]];
code:
#include<iostream>#include<stdio.h>using namespace std;#define maxn 110char s1[maxn],s2[maxn];int d[maxn][maxn];int match[90][90];void Init(){ match['A']['C']=match['A']['T']=match['C']['A']=match['T']['A']=match['T']['-']=match['-']['T']=-1; match['A']['A']=match['C']['C']=match['G']['G']=match['T']['T']=match['-']['-']=5; match['A']['G']=match['C']['T']=match['G']['A']=match['G']['T']=match['G']['-']=match['T']['C']=match['T']['G']=match['-']['G']=-2; match['C']['G']=match['A']['-']=match['G']['C']=match['-']['A']=-3; match['C']['-']=match['-']['C']=-4;}int main(){ Init(); int t; int len1,len2; cin>>t; while(t--){ cin>>len1>>s1; cin>>len2>>s2; d[0][0]=0; for(int i=1;i<=len1;i++) d[i][0]=d[i-1][0]+match[s1[i-1]]['-']; for(int i=1;i<=len2;i++) d[0][i]=d[0][i-1]+match['-'][s2[i-1]]; for(int a=1;a<=len1;a++){ for(int b=1;b<=len2;b++){ d[a][b]=max(d[a-1][b-1]+match[s1[a-1]][s2[b-1]],d[a-1][b]+match[s1[a-1]]['-']); d[a][b]=max(d[a][b],d[a][b-1]+match['-'][s2[b-1]]); } } cout<<d[len1][len2]<<endl; } return 0;}
0 0
- POJ 1080-Human Gene Functions(DP)
- Human Gene Functions(POJ 1080)
- POJ 1080 Human Gene Functions(DP)
- 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 1258 Agri-Net
- Lucene框架
- android EditText如何禁止输入内容
- linux系统chown命令解析
- Human Gene Functions(POJ 1080)
- 2014年度总结
- XP系统下虚拟机无法通过NAT连接网络
- jvm内存
- .Net中的反射
- 前面搭建好环境后,cocos2dx3.3如何新建项目?
- Android 在线音乐播放器
- Java并发学习笔记(六)-互斥性和内存可见性
- 算法分析与设计