WOJ1289-DNA

A DNA chain is a sequence of proteins of 4 types. The types are encoded using the characters 'A', 'C', 'G', 'T'. Two proteins are called
complementary if one is of type 'A' and the other is of type 'T', or if one is of type 'C' and the other is of type 'G'. Two DNA chains are called
complementary if they have equal length, and the i-th protein in the first chain and the i-th protein in the second chain are
complementary for all possible values of i.

You will be given strings first and second, representing two DNA chains of equal length. Your goal is to make the two chains complementary. To do this, you can perform a number of replacements, where each replacement involves changing a single protein in either one of the chains to a
different type. Return the minimum number of replacements required to achieve your goal.

输入格式

Each case contains two lines, that are the first and the second string: the first will contain between 1 and 50 characters, inclusive. And the second will contain the same number of characters as first. Each character in the first and the second string will be 'A', 'C', 'G' or 'T'.
Input ends with a single line of "#".

输出格式

For each case, output an integer on a single line, that is the minimum number of replacements required.

样例输入

ACGT
TGCA
ACGT
ACGT
ATAGTACCAC
CTTATTGGGT
#

样例输出

0
4
6


#include<stdio.h>
#include<string.h>
int main(){
    char str[2][55];
    int n,l,i;
    while(scanf("%s",str[0])){
    	if(str[0][0]=='#') break;
    	scanf("%s",str[1]);
    	n=0;
    	l=strlen(str[0]);
		for(i=0;i<l;i++){
			if(str[0][i]=='A'){
				if(str[1][i]!='T') n++;
			}
			else if(str[0][i]=='T'){
				if(str[1][i]!='A') n++;	
			}
			else if(str[0][i]=='C'){
				if(str[1][i]!='G') n++;
			}	
			else if(str[0][i]=='G')
				if(str[1][i]!='C') n++;	
		} 
		printf("%d\n",n);
	}
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值