HDU 5590 ZYB's Biology 水题

ZYB’s Biology

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5590

Description

ZYB(ZJ−267)在NOIP拿到600分之后开始虐生物题,他现在扔给你一道简单的生物题:给出一个DNA序列和一个RNA序列,
问它们是否配对。

DNA序列是仅由A,C,G,T组成的字符串,RNA序列是仅由A,C,G,U组成的字符串。

DNA和RNA匹配当且仅当每个位置上A与U,T与A,C与G,G与C匹配。

Input

第一行一个整数T表示数据组数。

对于每组数据:

第一行一个整数N表示DNA和RNA序列的长度.

第二行一个长度为N的字符串A表示DNA序列.

第三行一个长度为N的字符串B表示RNA序列.

1≤T≤10,1≤N≤100

Output

对于每组数据,输出一行YES或NO,表示是否匹配.

Sample Input

2
4
ACGT
UGCA
4
ACGT
ACGU

Sample Output

YES
NO

HINT

 

题意

 

题解:

水题。。

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s1[1500],s2[1500];

int main()
{
    int t;scanf("%d",&t);
    for(int cas=1;cas<=t;cas++)
    {
        int n;
        scanf("%d%s%s",&n,s1,s2);
        int flag = 1;
        for(int i=0;i<n;i++)
        {
            if(s1[i]=='A' && s2[i] == 'U') continue;
            if(s1[i]=='T' && s2[i] == 'A') continue;
            if(s1[i]=='C' && s2[i] == 'G') continue;
            if(s1[i]=='G' && s2[i] == 'C') continue;
            flag = 0;
            break;
        }
        if(flag==0)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

 

    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/5023314.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞