#P10114. [LMXOI Round 1] Size
[LMXOI Round 1] Size
Background
On a pitch-dark night, the witch took LMX away. HQZ, in order to save LMX, must complete the task given by the witch.
Problem Description
The witch gives a sequence of length . The witch wants to compute:
$$\sum\limits_{i=1}^{ n}\sum\limits_{j=1}^{n}{((d_i\oplus d_j)+(d_i \otimes d_j))}$$Here, is defined as the number of bits in the binary representation of the sum of two numbers in binary addition, and is defined as the number of bits in the binary representation of the difference between the larger number and the smaller number.
Input Format
The first line contains an integer , the length of the sequence.
The second line contains non-negative integers, representing the sequence .
Output Format
Output one integer in one line, representing the answer.
2
1 3
7
10
114514 19 19 810 1477 44151 15260 369 2010 222
1396
Hint
Sample Explanation #1
As shown in the table below, the answer is .
For of the testdata, it is guaranteed that $1 \le n\le 2\times 10^6,\sum\limits d_i\le5\times10^7$。
Constraints
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| Subtask #1 | |||
| Subtask #2 | None | ||
| Subtask #3 | is a power of | ||
| Subtask #4 | None |
Translated by ChatGPT 5