daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Oct 20th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define mod 1000000007
  2. int Solution::cntBits(vector<int> &A) {
  3.     long long int s = 0, n = 32,
  4.     ones=0, zeroes=0;
  5.    
  6.     while(n--) {
  7.         ones =0; zeroes=0;
  8.         for(int i = 0; i < A.size(); i++) {    
  9.             if(A[i]%2 == 1){
  10.                 ones++;
  11.                 //ones[n]=ones[n]%mod;
  12.             }
  13.             else{
  14.                 zeroes++;
  15.                //in zeroes[n]=zeroes[n]%mod;
  16.             }
  17.             A[i] = A[i] / 2;
  18.            
  19.         }
  20.         s += ones*zeroes;
  21.         s = s%mod;
  22.     }
  23.     return (2 * s)%mod;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top