• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            poj1080

            Human Gene Functions
            Time Limit: 1000MS Memory Limit: 10000K
            Total Submissions: 12791 Accepted: 7075

            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.

            Input

            The input consists of T test cases. The number of test cases ) (T is given in the first line of the input file. 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 
            這題是最長公共子列的變形
            但是我wa了兩遍,為什么呢,最后的答案不一定是正數
            所以在賦初值的時候要賦為負的
              1#include<stdio.h>
              2#include<string.h>
              3#include<math.h>
              4int a[10][10],l1,l2;
              5char s1[150],s2[150];
              6int f[150][150],f1[150],f2[150];
              7void init()
              8{
              9    int i;
             10    scanf("%d %s",&l1,&s1);
             11    for (i=1; i<=l1 ; i++ )
             12    {
             13        switch (s1[i-1])
             14        {
             15        case 'A':
             16            f1[i]=1;
             17            break;
             18        case 'C':
             19            f1[i]=2;
             20            break;
             21        case 'G':
             22            f1[i]=3;
             23            break;
             24        case 'T':
             25            f1[i]=4;
             26            break;
             27        }

             28    }

             29    scanf("%d %s",&l2,&s2);
             30    for (i=1; i<=l2 ; i++ )
             31    {
             32        switch (s2[i-1])
             33        {
             34        case 'A':
             35            f2[i]=1;
             36            break;
             37        case 'C':
             38            f2[i]=2;
             39            break;
             40        case 'G':
             41            f2[i]=3;
             42            break;
             43        case 'T':
             44            f2[i]=4;
             45            break;
             46        }

             47    }

             48}

             49int max(int a,int b)
             50{
             51    if (a>b) return a;
             52    else return b;
             53}

             54void work()
             55{
             56    int i,j;
             57    for (i=0; i<150;i++ )
             58    {
             59        for (j=0;j<150 ;j++ )
             60        {
             61            f[i][j]=-100000000;
             62        }

             63    }

             64    f[0][0]=0;
             65    for (i=1; i<=l1 ; i++ )
             66        f[i][0]=f[i-1][0]+a[f1[i]][5];
             67    for (i=1; i<=l2; i++)
             68        f[0][i]=f[0][i-1]+a[5][f2[i]];
             69    for (i=1; i<=l1 ; i++ )
             70    {
             71        for (j=1; j<=l2; j++ )
             72        {
             73            f[i][j]=max(f[i][j],f[i-1][j-1]+a[f1[i]][f2[j]]);
             74            f[i][j]=max(f[i][j],f[i-1][j]+a[f1[i]][5]);
             75            f[i][j]=max(f[i][j],f[i][j-1]+a[5][f2[j]]);
             76        }

             77    }

             78}

             79int main()
             80{
             81    int t,i;
             82    scanf("%d",&t);
             83    for (i=1; i<=4 ; i++ ) a[i][i]=5;
             84    a[1][2]=-1;
             85    a[1][3]=-2;
             86    a[1][4]=-1;
             87    a[1][5]=-3;
             88    a[2][1]=-1;
             89    a[2][3]=-3;
             90    a[2][4]=-2;
             91    a[2][5]=-4;
             92    a[3][1]=-2;
             93    a[3][2]=-3;
             94    a[3][4]=-2;
             95    a[3][5]=-2;
             96    a[4][1]=-1;
             97    a[4][2]=-2;
             98    a[4][3]=-2;
             99    a[4][5]=-1;
            100    a[5][1]=-3;
            101    a[5][2]=-4;
            102    a[5][3]=-2;
            103    a[5][4]=-1;
            104    a[5][5]=0;
            105    while (t)
            106    {
            107        init();
            108        work();
            109        printf("%d\n",f[l1][l2]);
            110        t--;
            111    }

            112    return 0;
            113}

            114

            posted on 2012-02-20 17:20 jh818012 閱讀(208) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            少妇无套内谢久久久久| 国产福利电影一区二区三区,免费久久久久久久精 | 久久国产三级无码一区二区| 色综合久久久久久久久五月 | 久久天天躁狠狠躁夜夜不卡| A级毛片无码久久精品免费| 久久影院久久香蕉国产线看观看| 一本一道久久a久久精品综合| 日本人妻丰满熟妇久久久久久| 夜夜亚洲天天久久| 亚洲国产欧美国产综合久久| 久久福利青草精品资源站免费| 久久亚洲国产成人影院| 婷婷久久综合九色综合98| 久久精品国产99国产精品导航| 97超级碰碰碰碰久久久久| 久久伊人五月丁香狠狠色| 久久国产V一级毛多内射| 国内精品久久久久影院日本| 狠狠精品久久久无码中文字幕| 久久久精品国产Sm最大网站| 久久婷婷久久一区二区三区| 亚洲av日韩精品久久久久久a| 一级A毛片免费观看久久精品| 精品国产乱码久久久久久浪潮| 2021精品国产综合久久| 久久亚洲精品无码AV红樱桃| 亚洲AV日韩AV永久无码久久| 亚洲女久久久噜噜噜熟女| 欧美激情一区二区久久久| 国内精品伊人久久久影院| 青青热久久国产久精品 | 亚洲欧美日韩久久精品第一区| 午夜精品久久久久久影视riav| 亚洲精品美女久久久久99小说 | 国产精品久久久久一区二区三区| 狠狠色丁香婷婷久久综合不卡| 欧美熟妇另类久久久久久不卡| 精品少妇人妻av无码久久| 无码精品久久久天天影视| 久久99国产综合精品|