公式不会推的题 E. Mahmoud and Ehab and the xor-MST

原题地址:http://codeforces.com/contest/959/problem/E

这里写图片描述

序列我们可以知道是这样子的.,问题就是如何去求公式,不会推,日后再补

#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, ans = 0;
    scanf("%I64d", &n);
    n--;
    for (long long i = 1; i <= n; i <<= 1)
        ans += ((n - i) / (i << 1) + 1) * i;
    printf("%I64d", ans);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/yiqzq/article/details/81502861