ZYB's Biology
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 63 Accepted Submission(s): 52
Problem Description
After getting
600
scores in NOIP
ZYB(ZJ−267)
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.
he gives you a DNA
matched.
The DNA
DNA
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.
1≤T≤10
,1≤N≤100![]()
For each teatcase:
In the first line there is one number N
In the next line there is a string of length N
In the third line there is a string of length N
1≤T≤10
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
题意:问DNA序列和RNA序列是否匹配,DNA和RNA匹配当且仅当每个位置上A与U,T与A,C与G,G与C匹配。
水题,代码如下:
#include<cstdio>
#include<cstring>
char a[110],b[110];
int main()
{
int i,n,sign,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%s",a);
scanf("%s",b);
sign=1;
for(i=0;i<n;++i)
{
if(a[i]=='A'&&b[i]!='U')
{
sign=0;
break;
}
if(a[i]=='T'&&b[i]!='A')
{
sign=0;
break;
}
if(a[i]=='C'&&b[i]!='G')
{
sign=0;
break;
}
if(a[i]=='G'&&b[i]!='C')
{
sign=0;
break;
}
}
if(sign)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}