# HDU Human Gene Functions (DP)

Source: Internet
Author: User

Test instructions

The human genome consists of a, C, G, T.

There is a 5*5 gene table. Each cell has a value, called similarity. Example: A-c:-3. This means that if a and C are paired, then the similarity between the two IS-3 "p.s.:-and-no similarity, i.e.-and-cannot be paired"

Now give two gene fragments. (length is not necessarily equal)

Now you have to insert several-(blank) genes into the two-gene fragment, making the two gene fragments equal in length, and the resulting overall similarity value is the largest. "Again p.s.:-and--Can't pair"

Ideas:

Because-and-cannot match, so the number of insertions-is limited.

The first gene of str1 can be paired with the first or-str1 of a. Then,,,, soon saw the DP structure, and,

and the longest common strand of the same meaning,,,

DP equation: The maximum similarity value that can be obtained by the former J and str2 of the DP[I][J]:STR1.

Look at the code,

Code:

`intL1,l2;Chars1[ the], s2[ the];ints1[ the], s2[ the];inta[6][6]={{5,-1,-2,-1,-3},{-1,5,-3,-2,-4},{-2,-3,5,-2,-2},{-1,-2,-2,5,-1},{-3,-4,-2,-1, INF}};intdp[ the][ the];intMaxxintAintBintc) {    intt=Max (A, b); returnMax (t,c);}intMain () {intT; CIN>>T;  while(t--) {scanf ("%d",&L1); scanf ("%s", S1); scanf ("%d",&L2); scanf ("%s", S2); Rep (I,0, l1-1){            if(s1[i]=='A') s1[i]=0; Else if(s1[i]=='C') s1[i]=1; Else if(s1[i]=='G') s1[i]=2; Elses1[i]=3; } Rep (I,0, l2-1){            if(s2[i]=='A') s2[i]=0; Else if(s2[i]=='C') s2[i]=1; Else if(s2[i]=='G') s2[i]=2; Elses2[i]=3; } dp[0][0]=0; Rep (I,0, l2-1) {dp[0][i+1]=dp[0][i]+a[4][s2[i]]; } Rep (I,0, l1-1) {Dp[i+1][0]=dp[i][0]+a[s1[i]][4]; } Rep (I,1, L1) {Rep (J,1, L2) {Dp[i][j]=maxx (dp[i-1][j-1]+a[s1[i-1]][s2[j-1]],dp[i-1][j]+a[s1[i-1]][4],dp[i][j-1]+a[4][s2[j-1]] ); }} printf ("%d\n", Dp[l1][l2]); }    return 0;}`

HDU Human Gene Functions (DP)

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.