hdu 3747 Download 菜鸟杯

http://acm.hdu.edu.cn/showproblem.php?pid=3747

#include <iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
main()
{
      int n,min,ans[4],i;
      char p[55],q[55];
      while(scanf("%d",&n)!=EOF)
      {
        for(i=0;i<4;i++)
         ans[i]=0;
        cin>>p;
        cin>>q;
        for(i=0;i<n;i++)
        {
          if(p[i]!=q[i])
             ans[0]++;
          else
             ans[1]++;
          if(q[i]=='0')
             ans[2]++;
        }
        ans[1]++;
        ans[2]++;
        ans[3]=2+n-ans[2]+1;
        min=ans[0];
        for(i=0;i<4;i++)
          if(ans[i]<min)
            min=ans[i];
        printf("%d\n",min);
      }
}
            

你可能感兴趣的:(download)