[CF959E]Mahmoud and Ehab and the xor-MST题解

解法
又是一道结论题?
我的做法比较奇怪且没有证明

#include <cstdio>
#include <cmath>
#define ll long long

int main(){
    ll ans = 0;
    ll n, bs = 1;
    scanf("%I64d", &n);
    while (n > 1){
        ans += (n >> 1) * bs;
        n -= (n >> 1);
        bs <<= 1;
    }
    printf("%I64d", ans);
    return 0;
}

如果没看懂,请去
CF官方题解及其证明

原文地址:https://www.cnblogs.com/linzhengmin/p/10895963.html