poj 1080 Human Gene Functions
来源:互联网 发布:郑州数据分析师工资 编辑:程序博客网 时间:2024/06/05 03:20
针对三种情况进行最大值的求解,规模为100,只有使用动态规划。
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <vector>#include <cmath>#include <algorithm>#include <set>#include <map>#include <queue>#include <ctime>#define pb push_back#define ll long long#define mp make_pair#define f first#define s second#define pii pair < int, int >#define ull unsigned long long#define pll pair < ll, ll >#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)#define all(s) s.begin(), s.end()const int inf = (1ll << 31) - 1;const int maxn = (int) 1e5 + 10;#define max(a, b) ((a) > (b) ? (a) : (b))#define min(a, b) ((a) < (b) ? (a) : (b))using namespace std;int matrix[5][5] = {{-19931117, -3, -4, -2, -1}, {-3, 5, -1, -2, -1}, {-4, -1, 5, -3, -2}, {-2, -2, -3, 5, -2}, {-1, -1, -2, -2, 5}};int dp[110][110];char s1[110], s2[110];int T = 0, len1 = 0, len2 = 0;int change(char a){ if (a == 'A') { return 1; }else if (a == 'C') { return 2; }else if (a == 'G') { return 3; }else if (a == 'T') { return 4; }else { return 0; }}int comp(char a, char b){ int r = 0; int c = 0; r = change(a); c = change(b); return matrix[r][c]; } int main(){ //freopen("data_1080.txt", "r", stdin); while(scanf("%d", &T) != EOF) { for (int t = 0; t < T; t++) { memset(dp, 0, sizeof(dp)); scanf("%d%s", &len1, s1); scanf("%d%s", &len2, s2); dp[0][0] = 0; char *s11, *s22; s11= s1 - 1; s22 = s2 - 1; for (int i = 1; i <= len1; i++) { dp[i][0] = dp[i - 1][0] + comp(s11[i], 0); } for (int i = 1; i <= len2; i++) { dp[0][i] = dp[0][i - 1] + comp(s22[i], 0); } for (int i = 1; i <= len1; i++) { for (int j = 1; j <= len2; j++) { dp[i][j] = dp[i][j - 1] + comp(s22[j], 0); dp[i][j] = max(dp[i][j], dp[i-1][j] + comp(s11[i], 0)); dp[i][j] = max(dp[i][j], dp[i-1][j-1] + comp(s11[i], s22[j])); } } printf("%d\n", dp[len1][len2]); } } return 0;}
0 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
- iOS分页控制器
- 信息的存储和表示
- 超轻量级数据绑定框架DBinder。新鲜出炉!
- IBM实习项目经历一【基于jenkins的自动化控制平台】
- Assembly.Load,系统找不到指定的文件
- poj 1080 Human Gene Functions
- 线程与进程初理解!
- ubuntu下安装telnet功能
- 今天学习的PS基本操作
- "未能加载文件或程序集“XXX”或它的某一个依赖项。系统找不到指定的文件"的解决方案
- uva 10003 cutting sticks
- springmvc 过滤器问题 ,求解!
- 5.Android Textview 技巧
- 深入分析C++中声明与定义的区别