Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

Sum of XOR of All Pairs in an Array

Revision en1, by LunaticPriest, 2019-12-09 02:14:29

Hello Codeforces community, I am trying to find the sum of XOR of all pairs in an array, where: n < 3*10^5 and A[i] < 2^60. My algorithm works as follows: For each bit 0 to 59, find how many 0s and 1s there are. Then add (zero_count*one_count*bit_value) to the answer, and finally, print the answer MOD 1e10+7. I know that the algorithm is correct, but I'm still getting wrong answers. In the beginning, I was getting an overflow because of the bit-shifting, but I fixed it. I am taking mods everywhere, and I can't find where the bug is. Here is the code. Thanks a lot for taking your time and helping me.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English LunaticPriest 2019-12-09 02:14:29 672 Initial revision (published)