Submit Time:2022-08-10 08:06:30

运行 ID: 55189

#include <bits/stdc++.h> using namespace std; #define LL long long const int N =1e6+10; int t[N]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { LL x; cin>>x; for(int j=0;j<20;j++) t[j]+=(x>>j)&1; } LL ans=0; for(int i=1;i<=n;i++) { LL now=0; for(int j=0;j<20;j++) if(t[j]!=0) t[j]--,now+=(1<<j); ans+=pow(now,2); } cout<<ans<<endl; }