Skip to content

Instantly share code, notes, and snippets.

@degurii
Created January 20, 2019 04:41
#include <iostream>
using namespace std;
using ll = long long;
ll n, ans;
int main() {
cin >> n;
ans = 2 * n;
for (ll i = 1; n / 2 > 0; i++, n /= 2) {
ans += (1 << i) * (n / 2);
}
cout << ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment