hdu 1080 Human Gene Functions
来源:互联网 发布:谷嫂淘宝店叫什么名字 编辑:程序博客网 时间:2024/06/04 18:26
题目点我
LCS变种
#include <stdio.h>#include <stdlib.h>#include <string.h>#define inf 0x3f3f3f3f#define len 105char a[len], b[len];int dp[len][len], mat[len][len];int Max(int a, int b){ return a > b ? a : b;}int main(){ int T, i, j; mat['A']['A'] = mat['C']['C'] = mat['G']['G'] = mat['T']['T'] = 5; mat['A']['C'] = mat['C']['A'] = mat['A']['T'] = mat['T']['A'] = mat['-']['T'] = -1; mat['A']['G'] = mat['G']['A'] = mat['C']['T'] = mat['T']['C'] = mat['G']['T'] = mat['T']['G'] = mat['-']['G'] = -2; mat['-']['A'] = mat['C']['G'] = mat['G']['C'] = -3; mat['-']['C'] = -4; scanf("%d", &T); int len1, len2; while(T--){ scanf("%d%s%d%s", &len1, a, &len2, b); dp[0][0] = 0; for(i = 1; i <= len1; i++) dp[i][0] = dp[i-1][0] + mat['-'][a[i-1]]; for(j = 1; j <= len2; j++) dp[0][j] = dp[0][j-1] + mat['-'][b[j-1]]; for(i = 1; i <= len1; i++){ for(j = 1; j <= len2; j++){ dp[i][j] = Max(dp[i-1][j-1] + mat[a[i-1]][b[j-1]], Max(dp[i-1][j] + mat['-'][a[i-1]], dp[i][j-1] + mat['-'][b[j-1]])); } } printf("%d\n", dp[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
- Smart_ptr源码剖析和问题探究
- 实现软键盘弹出时,可以在软键盘上方通过滑动显示Activity从上到下任意位置
- JUnit中Failure、Error区别
- [leetcode 97]Interleaving String
- android 读取原始(Raw)资源 作为数据库文件
- hdu 1080 Human Gene Functions
- mac各种快捷键汇总
- 无root手机版抓android包工具,超好用
- hdu 2199 Can you solve this equation?
- Qt 鼠标右击菜单建立
- 【原文件】tinyxmlerror.cpp
- vba如何连接db2数据库
- iphone 6plus 下app里的状态栏和界面会被放大的问题
- POJ2387(最短路基础)