175812025-07-26 11:05:58KristófAutókódoláscpp17Wrong answer 0/501ms552 KiB
#include <iostream>
#include <cmath>

using namespace std;



int main()
{
    long long a;
    long long tmp1;
    //long long mina,maxa;
    //cin>>a;
    a=pow(10,12);
    //printbinary(a);
    int n=0;
    while((1LL<<n) <=a) n++;
    //cout<<n;
    if((int)log2(a)!=(int)log2(a+1))
        {
        cout<<"-1\n";
        }
    else
        {
        bool b=false;
        for(long long j=0;j<=n;j++)
            {
            if(!(a & (1LL<<j)))
                {
                b=true;
                //continue;
                }
            else
                {
                if(b)
                    {
                    tmp1=(1LL<<(j-1));
                    //cout<<0+pow(2,j-1)<<endl;
                    //printbinary(tmp1);
                    cout<<a-tmp1<<endl;
                    //printbinary(a-tmp1);//<<"\n";
                    break;
                    }
                }
            }
        }
    int oc=0;
    bool b=false;
    int tmp;
    for(int i=0;i<=n;i++)
        {
        if(a & (1LL<<i))
            {
            if(b==false)
                {
                tmp=i;
                }
            b=true;
            oc++;
            }
        else
            {
            if(b)
                {
                break;
                }
            }

        }
    //cout<<((1*1LL)<<tmp+1)<<" ";
    //printbinary(a+((1*1LL)<<tmp+1)+(pow(2,oc-1)-1));
    cout<<a+((1*1LL)<<tmp)+((1LL<<(oc-1))-1);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms500 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms500 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/41ms316 KiB
9Wrong answer0/41ms316 KiB
10Wrong answer0/41ms404 KiB
11Wrong answer0/41ms316 KiB
12Wrong answer0/41ms316 KiB
13Wrong answer0/41ms316 KiB
14Wrong answer0/41ms552 KiB
15Wrong answer0/41ms316 KiB
16Wrong answer0/41ms316 KiB
17Wrong answer0/41ms316 KiB