POJ 1080 Human Gene Functions
来源:互联网 发布:sql union和union all 编辑:程序博客网 时间:2024/05/16 01:30
最长公共子串的变形题。
要初始化第一行第一列。
下面是代码:
#include <stdio.h>int max(int a,int b,int c){ if(a<b) { a=b; } if(a<c) { a=c; } return a;}int find(char c1,char c2){ if(c1==c2) { return 5; } else if(c1=='A'&&c2=='C') { return -1; } else if(c1=='A'&&c2=='G') { return -2; } else if(c1=='A'&&c2=='T') { return -1; } else if(c1=='A'&&c2=='-') { return -3; } else if(c1=='C'&&c2=='A') { return -1; } else if(c1=='C'&&c2=='G') { return -3; } else if(c1=='C'&&c2=='T') { return -2; } else if(c1=='C'&&c2=='-') { return -4; } else if(c1=='G'&&c2=='A') { return -2; } else if(c1=='G'&&c2=='C') { return -3; } else if(c1=='G'&&c2=='T') { return -2; } else if(c1=='G'&&c2=='-') { return -2; } else if(c1=='T'&&c2=='A') { return -1; } else if(c1=='T'&&c2=='C') { return -2; } else if(c1=='T'&&c2=='G') { return -1; } else if(c1=='T'&&c2=='-') { return -1; } else if(c1=='-'&&c2=='A') { return -3; } else if(c1=='-'&&c2=='C') { return -4; } else if(c1=='-'&&c2=='G') { return -2; } else if(c1=='-'&&c2=='T') { return -1; } return 0;}int main(){ int dp[105][105],t; scanf("%d",&t); int len1 ,len2,i,j; char s1[105],s2[105]; while(t--) { scanf("%d%s%d%s",&len1,s1,&len2,s2); dp[0][0]=0; for(i=0;i<len1;i++) { dp[i+1][0]=dp[i][0]+find(s1[i],'-'); } for(i=0;i<len2;i++) { dp[0][i+1]=dp[0][i]+find('-',s2[i]); } for(i=0;i<len1;i++) { for(j=0;j<len2;j++) { dp[i+1][j+1]=max(dp[i+1][j]+find('-',s2[j]),dp[i][j]+find(s1[i],s2[j]),dp[i][j+1]+find(s1[i],'-')); } } printf("%d\n",dp[len1][len2]); } return 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
- 构造/析构函数中不要调用虚函数
- uva 10673 - Play with Floor and Ceil(欧几里得算法)
- 论文学习笔记:BigTable
- 什么时候使用接口?什么时候使用抽象?选择Java接口还是抽象类
- HDU 1007 Quoit Design 最近点对问题
- POJ 1080 Human Gene Functions
- 基础篇完结,个人小总结
- 树的双亲表示法
- JVM的GC简介和实例
- easyui 使用笔记
- 一个案例引发的思考
- HDU4608:I-number
- Ubuntu下添加开机启动脚本
- Linux命令英文全称