ZROI#984
众所周知,异或是不进位的加法,也就是\(a\: xor \: b\le a+b\).
所以要最大化答案就全加起来好了.
\(Code:\)
#include <iostream>
#include <cstdlib>
#include <cstdio>
#define rint read<int>
#define int long long
template < class T >
inline T read () {
T x = 0 , f = 1 ; char ch = getchar () ;
while ( ch < '0' || ch > '9' ) {
if ( ch == '-' ) f = - 1 ;
ch = getchar () ;
}
while ( ch >= '0' && ch <= '9' ) {
x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
ch = getchar () ;
}
return f * x ;
}
const int N = 1e6 + 100 ;
int n , ans ;
signed main () {
n = rint () ;
for (int i = 1 ; i <= n ; ++ i) ans += rint () ;
printf ("%lld\n" , ans ) ;
return 0 ;
}
May you return with a young heart after years of fighting.