原题地址: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;
}