hiho week 211 register

Ended

Participants:209

Verdict:Accepted
Score:100 / 100
Submitted:2018-07-18 07:40:04

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
27
28
29
30
#include <cstdio>
#include <cstring>
using namespace std;
int main(void)
{
  int c[32], b[32];
  memset(c, 0, sizeof(c));
  for (int i = 0; i < 32; ++i)
    b[i] = (1 << i);
  int nN;
  scanf("%d", &nN);
  for (int i = 0; i < nN; ++i)
  {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < 32; ++j)
      c[j] += int((x&b[j]) != 0);
  }
  long long nDist = 0;
  for (int i = 0; i < 32; ++i)
  {
    long long s = nN;
    s -= c[i];
    s *= c[i];
    nDist += s;
  }
  printf("%lld\n", nDist);
  return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX