Advertisement
erfanul007

Untitled

Jan 18th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t,j;
  5. freopen("hamming.in","r",stdin);
  6. scanf("%d",&t);
  7. for(j=0;j<t;j++){
  8. int i,n,mn,cnt=0,acnt=0,ocnt=0;
  9. scanf("%d",&n);
  10. char s[2019],e[2019];
  11. scanf("%s",s);
  12. scanf("%s",e);
  13. for(i=0;i<n;i++){
  14. if(s[i]==e[i]){
  15. if(s[i]=='0')
  16. ocnt++;
  17. else if(s[i]=='1')
  18. acnt++;
  19. continue;
  20. }
  21. cnt++;
  22. }
  23. mn=ocnt;
  24. if(acnt<ocnt)
  25. mn=acnt;
  26. cnt=cnt+mn+mn;
  27. printf("%d\n",cnt);
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement