HDOJ 题目1080 Human Gene Functions(DP)
来源:互联网 发布:centos 软件选择 编辑:程序博客网 时间:2024/05/16 07:12
Human Gene Functions
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2795 Accepted Submission(s): 1583
Problem Description
It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose human diseases and to design new drugs for them.
A human gene can be identified through a series of time-consuming biological experiments, often with the help of computer programs. Once a sequence of a gene is obtained, the next job is to determine its function. One of the methods for biologists to use in determining the function of a new gene sequence that they have just identified is to search a database with the new gene as a query. The database to be searched stores many gene sequences and their functions – many researchers have been submitting their genes and functions to the database and the database is freely accessible through the Internet.
A database search will return a list of gene sequences from the database that are similar to the query gene. Biologists assume that sequence similarity often implies functional similarity. So, the function of the new gene might be one of the functions that the genes from the list have. To exactly determine which one is the right one another series of biological experiments will be needed.
Your job is to make a program that compares two genes and determines their similarity as explained below. Your program may be used as a part of the database search if you can provide an efficient one.
Given two genes AGTGATG and GTTAG, how similar are they? One of the methods to measure the similarity of two genes is called alignment. In an alignment, spaces are inserted, if necessary, in appropriate positions of the genes to make them equally long and score the resulting genes according to a scoring matrix.
For example, one space is inserted into AGTGATG to result in AGTGAT-G, and three spaces are inserted into GTTAG to result in –GT--TAG. A space is denoted by a minus sign (-). The two genes are now of equal length. These two strings are aligned:
AGTGAT-G
-GT--TAG
In this alignment, there are four matches, namely, G in the second position, T in the third, T in the sixth, and G in the eighth. Each pair of aligned characters is assigned a score according to the following scoring matrix.
* denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9.
Of course, many other alignments are possible. One is shown below (a different number of spaces are inserted into different positions):
AGTGATG
-GTTA-G
This alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is better than the previous one. As a matter of fact, this one is optimal since no other alignment can have a higher score. So, it is said that the similarity of the two genes is 14.
A human gene can be identified through a series of time-consuming biological experiments, often with the help of computer programs. Once a sequence of a gene is obtained, the next job is to determine its function. One of the methods for biologists to use in determining the function of a new gene sequence that they have just identified is to search a database with the new gene as a query. The database to be searched stores many gene sequences and their functions – many researchers have been submitting their genes and functions to the database and the database is freely accessible through the Internet.
A database search will return a list of gene sequences from the database that are similar to the query gene. Biologists assume that sequence similarity often implies functional similarity. So, the function of the new gene might be one of the functions that the genes from the list have. To exactly determine which one is the right one another series of biological experiments will be needed.
Your job is to make a program that compares two genes and determines their similarity as explained below. Your program may be used as a part of the database search if you can provide an efficient one.
Given two genes AGTGATG and GTTAG, how similar are they? One of the methods to measure the similarity of two genes is called alignment. In an alignment, spaces are inserted, if necessary, in appropriate positions of the genes to make them equally long and score the resulting genes according to a scoring matrix.
For example, one space is inserted into AGTGATG to result in AGTGAT-G, and three spaces are inserted into GTTAG to result in –GT--TAG. A space is denoted by a minus sign (-). The two genes are now of equal length. These two strings are aligned:
AGTGAT-G
-GT--TAG
In this alignment, there are four matches, namely, G in the second position, T in the third, T in the sixth, and G in the eighth. Each pair of aligned characters is assigned a score according to the following scoring matrix.
* denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9.
Of course, many other alignments are possible. One is shown below (a different number of spaces are inserted into different positions):
AGTGATG
-GTTA-G
This alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is better than the previous one. As a matter of fact, this one is optimal since no other alignment can have a higher score. So, it is said that the similarity of the two genes is 14.
Input
The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. Each test case consists of two lines: each line contains an integer, the length of a gene, followed by a gene sequence. The length of each gene sequence is at least one and does not exceed 100.
Output
The output should print the similarity of each test case, one per line.
Sample Input
2 7 AGTGATG 5 GTTAG 7 AGCTATT 9 AGCTTTAAA
Sample Output
14 21
Source
Asia 2001, Taejon (South Korea)
Recommend
We have carefully selected several similar problems for you: 1227 1502 1422 3008 1500
题目大意:给你两个字符串,给出两个字符匹配匹配所能获得的价值,两个字符串,你可以往一个里边填空格使两个串一样长,问最大获得的价值
ac代码
153501132015-11-02 15:08:54Accepted10800MS1632K1210 BG++XY_
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;int mc[330][330];void fun(){ mc['A']['A']=mc['C']['C']=mc['G']['G']=mc['T']['T']=5; mc['A']['C']=mc['C']['A']=mc['A']['T']=mc['T']['A']=mc[' ']['T']=mc['T'][' ']=-1; mc['A']['G']=mc['G']['A']=mc['C']['T']=mc['T']['C']=mc['T']['G']=mc['G']['T']=mc[' ']['G']=mc['G'][' ']=-2; mc['A'][' ']=mc[' ']['A']=mc['G']['C']=mc['C']['G']=-3; mc[' ']['C']=mc['C'][' ']=-4;}char str1[110],str2[110];int dp[110][110];int main(){ int t; fun(); scanf("%d",&t); while(t--) { int len1,len2; scanf("%d%s%d%s",&len1,str1+1,&len2,str2+1); dp[0][0]=0; int i,j; for(i=1;i<=len1;i++) dp[i][0]=dp[i-1][0]+mc[str1[i]][' ']; for(i=1;i<=len2;i++) dp[0][i]=dp[0][i-1]+mc[' '][str2[i]]; for(i=1;i<=len1;i++) for(j=1;j<=len2;j++) { dp[i][j]=max(dp[i-1][j]+mc[str1[i]][' '],dp[i][j-1]+mc[' '][str2[j]]); dp[i][j]=max(dp[i][j],dp[i-1][j-1]+mc[str1[i]][str2[j]]); } printf("%d\n",dp[len1][len2]); }}
0 0
- HDOJ 题目1080 Human Gene Functions(DP)
- HDOJ 1080 Human Gene Functions(DP)
- POJ 1080-Human Gene Functions(DP)
- POJ 1080 Human Gene Functions(DP)
- Human Gene Functions--DP
- hdoj 1080 Human Gene Functions 【LCS变形】
- POJ 1080 && HDU 1080 Human Gene Functions(dp)
- poj 1080 Human Gene Functions(动态规划:经典DP)
- POJ 1080-Human Gene Functions(DP:LCS变型)
- poj 1080 Human Gene Functions (dp,LCS)
- POJ 1080 Human Gene Functions(字符串匹配得分,dp)
- hdu 1080 Human Gene Functions--DP
- POJ 1080 Human Gene Functions DP(LCS)
- POJ 1080 Human Gene Functions DP
- hdu 1080 Human Gene Functions(dp)
- HDU 1080 Human Gene Functions dp
- hdu 1080 dp Human Gene Functions
- hdu 1080 Human Gene Functions (dp)
- AndroidManifest.xml文件解析
- Unity5 如何做资源管理和增量更新
- Hibernate 的事务与并发
- Android学习记录2
- 安卓&android工程逆向记录
- HDOJ 题目1080 Human Gene Functions(DP)
- C++笔试中常见的小程序
- hihocoder 挑战赛后学习 #1245 #1246
- javascript实现城市级联操作
- java实现生产者消费者问题
- object-c编程tips-jastor自动解析
- SecureCRT背景及根据不同文件类型颜色的设置
- 2015.07.07_检验电话号码是否是正确的电话号码
- WebView缩放显示图片