175762025-07-26 10:04:31KristófAutókódoláscpp17Wrong answer 22/501ms564 KiB
#include <iostream>
#include <cmath>

using namespace std;

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

        }
    cout<<a+(1<<tmp)+(pow(2,oc-1)-1);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms500 KiB
3Accepted2/21ms508 KiB
4Wrong answer0/21ms508 KiB
5Partially correct1/21ms316 KiB
6Partially correct1/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms564 KiB
10Accepted4/41ms500 KiB
11Accepted4/41ms316 KiB
12Wrong answer0/41ms316 KiB
13Wrong answer0/41ms316 KiB
14Wrong answer0/41ms404 KiB
15Wrong answer0/41ms316 KiB
16Wrong answer0/41ms316 KiB
17Wrong answer0/41ms316 KiB