zoukankan      html  css  js  c++  java
  • 5590

    ZYB's Biology

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
    Total Submission(s): 560    Accepted Submission(s): 413


    Problem Description
    After getting 600 scores in NOIP ZYB(ZJ267) begins to work with biological questions.Now he give you a simple biological questions:
    he gives you a DNA sequence and a RNA sequence,then he asks you whether the DNA sequence and the RNA sequence are 
    matched.

    The DNA sequence is a string consisted of A,C,G,T;The RNA sequence is a string consisted of A,C,G,U.

    DNA sequence and RNA sequence are matched if and only if A matches U,T matches A,C matches G,G matches C on each position. 
     
    Input
    In the first line there is the testcase T.

    For each teatcase:

    In the first line there is one number N.

    In the next line there is a string of length N,describe the DNA sequence.

    In the third line there is a string of length N,describe the RNA sequence.

    1T10,1N100
     
    Output
    For each testcase,print YES or NO,describe whether the two arrays are matched.
     
    Sample Input
    2 4 ACGT UGCA 4 ACGT ACGU
     
    Sample Output
    YES NO
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
        int N,length,a[100],b[100],i,j,k;
        char temp;
        cin>>N;
        while(N--)
        {
            cin>>length;
            for(i=0;i<length;i++)
            {
            
                cin>>temp;
                if(temp=='A') a[i]=1;
                else if(temp=='C')a[i]=2;
                else if(temp=='G')a[i]=3;
                else if(temp=='T')a[i]=4;
            }
            for(j=0;j<length;j++)
            {
            
                cin>>temp;
                if(temp=='U') b[j]=1;
                else if(temp=='G')b[j]=2;
                else if(temp=='C')b[j]=3;
                else if(temp=='A')b[j]=4;
            }
            for(k=0;k<length;k++)
            {
                if(a[k]!=b[k]) break;
            }
            if(k<length) cout<<"NO"<<endl;
            else if(k==length) cout<<"YES"<<endl;
        }
        return 0;
    }
  • 相关阅读:
    ACM的算法分类 2015-04-16 14:25 22人阅读 评论(0) 收藏
    初学Larevel 2014-08-21 11:24 90人阅读 评论(0) 收藏
    初学PHP&MySQL 2014-05-31 12:40 92人阅读 评论(0) 收藏
    codeforces 570 E. Pig and Palindromes (dp)
    codeforces 570 D. Tree Requests (dfs序)
    poj 2157 Maze (bfs)
    cf 570 C. Replacement (暴力)
    cf 570B B. Simple Game(构造)
    cf 570 A. Elections
    hdu 1429胜利大逃亡(续) (bfs+状态压缩)
  • 原文地址:https://www.cnblogs.com/tt-t/p/5070990.html
Copyright © 2011-2022 走看看