Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t,j;
- freopen("hamming.in","r",stdin);
- scanf("%d",&t);
- for(j=0;j<t;j++){
- int i,n,mn,cnt=0,acnt=0,ocnt=0;
- scanf("%d",&n);
- char s[2019],e[2019];
- scanf("%s",s);
- scanf("%s",e);
- for(i=0;i<n;i++){
- if(s[i]==e[i]){
- if(s[i]=='0')
- ocnt++;
- else if(s[i]=='1')
- acnt++;
- continue;
- }
- cnt++;
- }
- mn=ocnt;
- if(acnt<ocnt)
- mn=acnt;
- cnt=cnt+mn+mn;
- printf("%d\n",cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement