首页 > 其他 > 详细

ZROI#984

时间:2019-09-15 20:36:47      阅读:195      评论:0      收藏:0      [点我收藏+]

ZROI#984

众所周知,异或是不进位的加法,也就是\(a^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 ;
}

ZROI#984

原文:https://www.cnblogs.com/Equinox-Flower/p/11523828.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!