Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
745 B
3
Indexable
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 100005
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define Ford(i,a,b) for ( int i = a; i >= b; i-- )
#define MOD 100000000000007
typedef long long ll;
using namespace std;
long long x,a[maxn],res = 0;
int d = 0;
void inp()
{
    cin >> x;
    For(l,0,40)
    For(r,0,40)
    {
        int u = r - l + 1;
        a[d++] = (x >> l) % (1ll << u);
    }
    sort(a,a+d);
    For(i,0,d - 1)
    if(a[i] != a[i+1]) res += a[i];
    cout << res;
}
void solve()
{

}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai1.inp","r")){
        freopen("bai1.inp","r",stdin);
    }
    inp();
    solve();
}
Leave a Comment