Let’s Go！！！

###### poj1080
#include <iostream>

using namespace std;

const int MAXN = 101;
int dp[MAXN][MAXN];
int score[5][5] =
{
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 change(char ch)
{
if (ch == 'A')
{
return 0;
}
else if (ch == 'C')
{
return 1;
}
else if (ch == 'G')
{
return 2;
}
else if (ch == 'T')
{
return 3;
}
else
{
return 4;
}
}

char A[MAXN], B[MAXN];

int maxs(int a, int b, int c)
{
return max(a, max(b, c));
}

void input()
{
int t, a, b;

cin >> t;

while (t--)
{
cin >> a;

for (int i = 0; i < a; i++)
{
cin >> A[i];
}

cin >> b;

for (int i = 0; i < b; i++)
{
cin >> B[i];
}

dp[0][0] = 0;

for (int i = 1; i <= a; i++)
{
dp[i][0] = dp[i - 1][0] + score[change(A[i - 1])][change('-')];
}

for (int i = 1; i <= b; i++)
{
dp[0][i] = dp[0][i - 1] + score[change('-')][change(B[i - 1])];
}

for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= b; j++)
{
dp[i][j] = maxs(dp[i][j - 1] + score[change('-')][change(B[j - 1])],
dp[i - 1][j] + score[change(A[i - 1])][change('-')],
dp[i - 1][j - 1] + score[change(A[i - 1])][change(B[j - 1])]);

}
}

cout << dp[a][b] << endl;
}
}

int main()
{
input();
return 0;
}

#### poj1080(LCS变形)

2016-05-26 18:35:13

#### 【poj1080】 Human Gene Functions

2016-08-12 15:28:57

#### poj 1080 Human Gene Functions 解题报告（附详细分析）

2013-11-27 22:19:08

#### POJ 1080 解题报告

2015-04-03 00:51:12

#### poj1080解题报告

2013-04-02 19:57:59

#### POJ1080

2012-07-06 15:15:47

#### POJ1080-Human Gene Functions

2011-07-31 12:14:54

#### LCS之poj1080

2014-11-06 13:02:46

#### poj1080(dp)

2016-12-06 10:00:09

#### poj1080 2010.2.20

2016-02-05 14:30:38

poj1080