hdoj 5590 ZYB's Biology 【水题】

本文介绍了一道关于DNA与RNA序列匹配的问题,探讨了如何判断一个DNA序列与一个RNA序列是否匹配,并提供了一个简单的模拟算法实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ZYB's Biology

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


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
 



水题,直接模拟。


AC代码:


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define INF 0x3f3f3f
#define eps 1e-8
#define MAXN (100+10)
#define MAXM (100000)
#define Ri(a) scanf("%d", &a)
#define Rl(a) scanf("%lld", &a)
#define Rf(a) scanf("%lf", &a)
#define Rs(a) scanf("%s", a)
#define Pi(a) printf("%d\n", (a))
#define Pf(a) printf("%.2lf\n", (a))
#define Pl(a) printf("%lld\n", (a))
#define Ps(a) printf("%s\n", (a))
#define W(a) while(a--)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define LL long long
#define lson o<<1, l, mid
#define rson o<<1|1, mid+1, r
#define ll o<<1
#define rr o<<1|1
using namespace std;
bool judge(char a, char b)
{
    if(a == 'A' && b == 'U') return true;
    if(a == 'T' && b == 'A') return true;
    if(a == 'C' && b == 'G') return true;
    if(a == 'G' && b == 'C') return true;
    return false;
}
int main()
{
    int t; Ri(t);
    W(t)
    {
        int n;
        char a[110], b[110];
        Ri(n);
        Rs(a); Rs(b);
        bool flag = true;
        for(int i = 0; i < n; i++)
        {
            if(!judge(a[i], b[i]))
            {
                flag = false;
                break;
            }
        }
        printf(flag ? "YES\n" : "NO\n");
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值