hiho week 211 register

Ended

Participants:209

Verdict:Accepted
Score:100 / 100
Submitted:2018-07-20 00:43:12

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<string.h>
#include<iostream>
#include <stdio.h>
using namespace std;
int main() {
    int n, t;
    int sum[32];
    while (cin >> n) {
        unsigned long long total = 0;
        int tn = n;
        memset(sum, 0, sizeof(sum));
        while (n--) {
            cin >> t;
            for (int i = 0; i < 32; i++) {
                if (t & (1 << i)) {
                    sum[i] += 1;
                }
            }
        }
        for (int i = 0; i < 32; i++) {
            total += (long long)sum[i] * (tn - sum[i]);
        }
        cout << total << endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX