138322025-01-08 20:43:16horkaAutókódoláscpp17Partially correct 48/501ms568 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool bit(int x, int i)
{
    return ((1LL<<i)&x);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin>>n;
    int el=n;
    for(int i=0; i<50; i++)
    {
        if(i!=0 && bit(n,i))
        {
            el^=(1LL<<i);
            el^=(1LL<<(i-1));
            break;
        }
    }
    for(int i=0; i<50; i++)
        if(n==((1LL<<i)-1)) el=n;
    cout<<(el==n?-1:el)<<"\n";
    int kov=n,hany=0,pos=0;
    for(int i=0; i<50; i++)
    {
        if(bit(n,i) && !bit(n,i+1))
        {
            pos=i+1;
            break;
        }
        if(bit(n,i)) hany++;
    }
    kov^=(1LL<<(pos));
    for(int i=0; i<pos; i++)
        if(bit(n,i)) kov^=(1LL<<i);
    int p=(1LL<<hany)-1;
    kov^=p;
   /* if(kov==n)
    {

    }*/
    cout<<(kov==n?-1:kov)<<"\n";
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms508 KiB
4Accepted2/21ms316 KiB
5Partially correct1/21ms316 KiB
6Partially correct1/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted4/41ms500 KiB
9Accepted4/41ms316 KiB
10Accepted4/41ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Accepted4/41ms316 KiB
14Accepted4/41ms568 KiB
15Accepted4/41ms388 KiB
16Accepted4/41ms316 KiB
17Accepted4/41ms316 KiB