求两个树的二进制位不同的个数。
#include<cstdio>
using namespace std;
int func(long long x)
{
int countx = 0;
while(x)
{
countx ++;
x = x&(x-1);
}
return countx;
}
long long s[1005];
int main()
{
//int x=9^15;
//cout<<func(x);
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lld",&s[i]);
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
long long tmp=s[i]^s[j];
ans+=func(tmp);
}
}
printf("%d",ans);
return 0;
}