Partially accepted, why not fully


#1

int Solution::hammingDistance(const vector &A)
{
int d=0;
int mod=1000000007;
for(int i=0;i<32;i++)
{
int set=0;
for(int j=0;j<A.size();j++)
{
if(A[j]&(1<<i))
set=(set+1)%mod;
}
int unset=(A.size()-set)%mod;
if(set==0 || unset==0)
continue;
d=(d+(set*unset)%mod)%mod;
}
return (d * 2)%mod;
}


#2

Hi, take long mod=1000000007 instead of int.
Also, check out this module: https://www.hackerearth.com/practice/math/number-theory/basic-number-theory-1/tutorial/


#3

yeah it works, but why? … please specify the reason
P.S. : I couldn’t find any reason on that link too.


#4

int*int can overflow.