ZROI#984
众所周知,异或是不进位的加法,也就是$a^b\le a+b$.
所以要最大化答案就全加起来好了.
$Code:$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
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 ;
}