Advertisement
Zeinab_Hamdy

Untitled

Nov 23rd, 2022
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. int differentBitsSumPairwise(vector<int> &arr, int n){
  3.     //bitset < 32 > bt;
  4.     long long ans=0;
  5.     int bits=32;
  6.     for(int i=0;i<bits ; i++){
  7.         int zero=0 , one=0;
  8.         for(int j=0;j<arr.size();j++){
  9.             if(arr[j]&1) one++;
  10.             else zero++;
  11.             arr[j]/=2;
  12.         }
  13.         ans +=2*one*zero ;
  14.     }
  15.  return ans;  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement