CF1368D AND, OR and square sum
题目描述
### 题面描述
给定 $n$ 个非负整数 $a_1,\cdots,a_n$。
你可以进行如下操作:选择两个不同的下标 $i,j$ 满足 $1\leq i,j\leq n$,并将 $a_i\gets a_i\ \mathsf{AND}\ a_j,\ a_j\gets a_i\ \mathsf{OR}\ a_j$,**两个赋值同时进行**。AND 是按位与,OR 是按位或。
你可以进行任意次操作。求操作后所有数的平方和的最大值,即 $\max \sum a_i^2$。
输入格式
无
输出格式
无
说明/提示
In the first sample no operation can be made, thus the answer is $ 123^2 $ .
In the second sample we can obtain the collection $ 1, 1, 7 $ , and $ 1^2 + 1^2 + 7^2 = 51 $ .
If $ x $ and $ y $ are represented in binary with equal number of bits (possibly with leading zeros), then each bit of $ x~\mathsf{AND}~y $ is set to $ 1 $ if and only if both corresponding bits of $ x $ and $ y $ are set to $ 1 $ . Similarly, each bit of $ x~\mathsf{OR}~y $ is set to $ 1 $ if and only if at least one of the corresponding bits of $ x $ and $ y $ are set to $ 1 $ . For example, $ x = 3 $ and $ y = 5 $ are represented as $ 011_2 $ and $ 101_2 $ (highest bit first). Then, $ x~\mathsf{AND}~y = 001_2 = 1 $ , and $ x~\mathsf{OR}~y = 111_2 = 7 $ .