ZR#984

ZR#984

解法:

异或的一个性质: $ a+b \geq a \bigoplus b$
所以一边读入一边把读进来的值加到答案就行了。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define LL long long
#define N 100010

LL n,ans,x;

int main() {
    scanf("%lld",&n);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%lld",&x);
        ans += x;
    }
    printf("%lld",ans);
    //system("pause");
    return 0;
}
posted @ 2019-09-24 21:23  西窗夜雨  阅读(151)  评论(0编辑  收藏  举报