POJ 1080 Humman Gene Function
来源:互联网 发布:mysql sql union 编辑:程序博客网 时间:2024/04/30 18:38
大意:每两个字母都对应着一个相应的值,现在通过对短的字符串添加‘-’来求可以得到的最大值。
注意初始化dp[0][i],dp[i][0]就OK了
#include<stdio.h>#include<string.h>#include<iostream>using namespace std;int zhuanhuan(char a,char b){ if(a==b) return 5; else if(a=='C'&&b=='A'||a=='A'&&b=='C'||a=='T'&&b=='A'||a=='A'&&b=='T'||a=='-'&&b=='T'||a=='T'&&b=='-') return -1; else if(a=='A'&&b=='G'||a=='G'&&b=='A'||a=='C'&&b=='T'||a=='T'&&b=='C'||a=='G'&&b=='T'||a=='T'&&b=='G'||a=='G'&&b=='-'||a=='-'&&b=='G') return -2; else if(a=='A'&&b=='-'||a=='-'&&b=='A'||a=='C'&&b=='G'||a=='G'&&b=='C') return -3; else if(a=='C'&&b=='-'||a=='-'&&b=='C') return -4;}int main(){ int t; scanf("%d",&t); while(t--) { int n,m; char s1[101],s2[101]; scanf("%d%s%d%s",&n,s1,&m,s2); int dp[101][101]; memset(dp,0,sizeof(dp)); for(int i=1;i<=m;i++) { dp[0][i]=dp[0][i-1]+zhuanhuan('-',s2[i-1]); } for(int i=1;i<=n;i++) { dp[i][0]=dp[i-1][0]+zhuanhuan(s1[i-1],'-'); } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { dp[i][j]=max(max(dp[i-1][j]+zhuanhuan(s1[i-1],'-'),dp[i][j-1]+zhuanhuan('-',s2[j-1])),dp[i-1][j-1]+zhuanhuan(s1[i-1],s2[j-1])); } } printf("%d\n",dp[n][m]); } return 0;}
0 0
- POJ 1080 Humman Gene Function
- Pku 1080 Humman Gene Function
- Pku 1080 Humman Gene Function 解题分析
- Pku 1080 Humman Gene Function 解题分析
- PUKOJ1080 Humman Gene Function
- Pku acm 1080 Humman Gene Function 动态规划题目解题报告(八)
- POJ 1080 HUMAN GENE FUNCTION
- POJ 1080--Human Gene Function
- 【算法刷题】poj 1080 Human Gene Function
- PKU ACM 1080-human gene function
- 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
- 练习题
- asp.net微信公众平台开发(3)微信消息封装及反射赋值
- TLV----Demo讲解
- java bitSet的学习
- 重构Button类,实现APP在大屏幕下用遥控器遥控,界面按钮在获取焦点下显示边框
- POJ 1080 Humman Gene Function
- 64、使用jQuery全局函数转换数组
- document.createElement()的用法
- hdu 2063 过山车
- poj 1274The Perfect Stall
- html,css等入门
- poj 1274The Perfect Stall(二分最大匹配法——匈牙利算法)
- INSTALL_FAILED_UID_CHANGED解决办法
- FatMouse's Speed