HDU 1080 Human Gene Functions
来源:互联网 发布:炫踪网络 ceo 编辑:程序博客网 时间:2024/05/16 14:01
读完这个题 一直以为添加空格 使得两个字符串一样长。 然后求最大相似度。。
做了半天没做出来。 又去读了遍题。 看到了 if necessary, in appropriate positions of the genes to make them equally long
然后醉了。。 知道之后就比较好做了。 d【i】【j】 代表 第一个字符串用了 i个字符,第二个字符串用了 j个字符 之后的相似度
比较简单了。 因为对于某一个字符 要不和空格匹配 要不和 字符匹配。 取一个最大值就好了。
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <cmath>#include <cstdlib>#include <string>#include <map>#include <vector>#include <set>#include <queue>#include <stack>#include <cctype>using namespace std;typedef long long LL;typedef unsigned long long ULL;#define MAXN 100+10#define INF (1<<30)#define mod 123456789int cal(char c){ if(c == 'A') return 0; if(c == 'C') return 1; if(c == 'G') return 2; if(c == 'T') return 3; if(c == ' ') return 4;}int math[MAXN][MAXN] = {{5,-1,-2,-1,-3}, {-1,5,-3,-2,-4}, {-2,-3,5,-2,-2}, {-1,-2,-2,5,-1}, {-3,-4,-2,-1,0}};int main (){ int t; scanf("%d",&t); while(t--){ int len1,len2; char s1[MAXN],s2[MAXN]; scanf("%d%s",&len1,s1+1); scanf("%d%s",&len2,s2+1); int d[MAXN][MAXN] = {0}; for(int i = 0; i <= len1; i++){ for(int j = 0; j <= len2; j++){ if(i == 0 && j == 0) continue; if(i == 0) d[i][j] = d[i][j-1] + math[4][cal(s2[j])]; else if(j == 0) d[i][j] = d[i-1][j] + math[cal(s1[i])][4]; else d[i][j] = max(d[i-1][j]+math[cal(s1[i])][4], max(d[i][j-1]+math[4][cal(s2[j])], d[i-1][j-1]+math[cal(s1[i])][cal(s2[j])])); //printf("%d %d %d\n",i,j,d[i][j]); } } printf("%d\n",d[len1][len2]); } return 0;}
0 0
- hdu 1080 Human Gene Functions
- HDU 1080 Human Gene Functions
- HDU 1080 Human Gene Functions
- 【Hdu】1080 Human Gene Functions
- HDU 1080 Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu-1080 Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu Human Gene Functions
- HDU Human Gene Functions
- hdu 1080 ;poj 1080 Human Gene Functions
- hdu 1080 Human Gene Functions--DP
- HDU 1080 || ZOJ 1027 Human Gene Functions
- hdu 1080 Human Gene Functions(dp)
- HDU 1080 Human Gene Functions dp
- Linux修改文件权限记录
- coffeescript的上下文
- maven构建下载包
- 我的macbook air只有一个耳机有声音,右边的耳机没有声音,原装耳机也是一样
- 如何修改 SAP 登录界面的文字(事务码SE61)
- HDU 1080 Human Gene Functions
- Jquery中toggle的用法
- 传参出错注意数据库连接问题
- window.close and self.close do not close the window in Chrome
- C++实现24位位图的灰度化
- 『转』android 程序中判断当前是否连接网络,网络是否可用
- 利用.dSYM和.app文件准确定位Crash位置
- Android 命令行手动编译打包详解
- 如何修改 SAP 登录后的背景图片(事务码 SMW0,SM30)