DNA和RNA的匹配(hdu5590)
2016-01-29 10:19
435 查看
题:Description
After getting scores in begins to work with biological questions.Now he give you a simple biological questions:
he gives you a sequence and a sequence,then he asks you whether the sequence and the sequence are
matched.
The sequence is a string consisted of ;The sequence is a string consisted of .
sequence and sequence are matched if and only if matches , matches , matches , matches on each position.
Input
In the first line there is the testcase .
For each teatcase:
In the first line there is one number .
In the next line there is a string of length ,describe the sequence.
In the third line there is a string of length ,describe the sequence.
,
Output
For each testcase,print or ,describe whether the two arrays are matched.
Sample Input
2
4
ACGT
UGCA
4
ACGT
ACGU
Sample Output
YES
NO
解法一:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int t;
char a1[200],a2[200];
scanf("%d",&t);
while(t--)
{
int n;
int h=0;
scanf("%d%s%s",&n,a1,a2);
for(int i=0;i<n;i++) //序列的长度
{
if(a1[i]=='A'&&a2[i]=='U')h++; //每配对一个就加一,如果h等于n则表明全部配对
if(a1[i]=='C'&&a2[i]=='G')h++;
if(a1[i]=='G'&&a2[i]=='C')h++;
if(a1[i]=='T'&&a2[i]=='A')h++;
}
if(h==n)printf("YES\n");
else printf("NO\n");
}
}
解法二:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int t;
char a1[200],a2[200];
scanf("%d",&t);
while(t--)
{
int n;
int h=0;
scanf("%d%s%s",&n,a1,a2);
for(int i=0;i<n;i++) //序列的长度
{
if(a1[i]=='A'&&a2[i]!='U')h=1; //有一个没配对成功就标记为一
if(a1[i]=='C'&&a2[i]!='G')h=1;
if(a1[i]=='G'&&a2[i]!='C')h=1;
if(a1[i]=='T'&&a2[i]!='A')h=1;
}
if(h==1)printf("NO\n");
else printf("YES\n");
}
}
After getting scores in begins to work with biological questions.Now he give you a simple biological questions:
he gives you a sequence and a sequence,then he asks you whether the sequence and the sequence are
matched.
The sequence is a string consisted of ;The sequence is a string consisted of .
sequence and sequence are matched if and only if matches , matches , matches , matches on each position.
Input
In the first line there is the testcase .
For each teatcase:
In the first line there is one number .
In the next line there is a string of length ,describe the sequence.
In the third line there is a string of length ,describe the sequence.
,
Output
For each testcase,print or ,describe whether the two arrays are matched.
Sample Input
2
4
ACGT
UGCA
4
ACGT
ACGU
Sample Output
YES
NO
解法一:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int t;
char a1[200],a2[200];
scanf("%d",&t);
while(t--)
{
int n;
int h=0;
scanf("%d%s%s",&n,a1,a2);
for(int i=0;i<n;i++) //序列的长度
{
if(a1[i]=='A'&&a2[i]=='U')h++; //每配对一个就加一,如果h等于n则表明全部配对
if(a1[i]=='C'&&a2[i]=='G')h++;
if(a1[i]=='G'&&a2[i]=='C')h++;
if(a1[i]=='T'&&a2[i]=='A')h++;
}
if(h==n)printf("YES\n");
else printf("NO\n");
}
}
解法二:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int t;
char a1[200],a2[200];
scanf("%d",&t);
while(t--)
{
int n;
int h=0;
scanf("%d%s%s",&n,a1,a2);
for(int i=0;i<n;i++) //序列的长度
{
if(a1[i]=='A'&&a2[i]!='U')h=1; //有一个没配对成功就标记为一
if(a1[i]=='C'&&a2[i]!='G')h=1;
if(a1[i]=='G'&&a2[i]!='C')h=1;
if(a1[i]=='T'&&a2[i]!='A')h=1;
}
if(h==1)printf("NO\n");
else printf("YES\n");
}
}
相关文章推荐
- c3p0连接池
- batch-GD, SGD, Mini-batch-GD, Stochastic GD, Online-GD -- 大数据背景下的梯度训练算法
- 转载:你所不知的 CSS ::before 和 ::after 伪元素用法
- JSP引入资源
- Java关键字之final详解
- 【团队分享】刀锋铁骑:常见Android Native崩溃及错误原因
- LNMP环境搭建-php
- 当一个从XIB创建的视图的子控制器在UI上不显示要想到视图控制器的autoresizingMask属性
- 理解Fragment生命周期
- 公司里的人际界线——北漂18年(41)
- android studio创建桌面插件widget
- 13. redis 高级:Java客户端
- 二、初始化方法
- charter 2-java对象和类
- 从零学习Swift<6>
- c++随机数
- Long Value输出方法
- Logback配置
- Android 开发绕不过的坑:你的 Bitmap 究竟占多大内存?
- Laravel 修改 支持 提示 “用户 xxx 存在”