21182022-12-20 12:28:451478Autókódoláscpp11Partially correct 48/503ms4200 KiB
#include <bits/stdc++.h>

using namespace std;


int main()
{
    //ifstream cin("be.txt");
    long long n;
    cin>>n;

    long long tempN = n;
    long long multTwo = 1;

    ///kisebb
    long long ans1 = 0;
    while(tempN > 0){
        ans1 += multTwo * (tempN%2);
        if(tempN%2 == 0 && tempN/2 > 0 && (tempN/2)%2 == 1){
        ///aktualis bit
           ans1 += multTwo;
        ///maradek
           tempN/=4;
           ans1 += tempN*4*multTwo;
           break;
        }
        multTwo *= 2;
        tempN /= 2;
    }

    if(ans1 == 1 || ans1 == n) cout<<-1<<'\n';
    else cout<<ans1<<'\n';

    ///nagyobb
    tempN = n;
    multTwo = 1;
    int numberOfZerosAtEnd = 0;
    while(tempN > 0 && tempN%2 == 0){
        numberOfZerosAtEnd++;
        multTwo *= 2;
        tempN /= 2;
    }
    //cout<<numberOfZerosAtEnd<<'\n';
    long long ans2 = 0;
    while(tempN > 0){
        if(tempN%2 == 1 && tempN/2 == 0 || (tempN/2)%2 == 0){
        ///aktualis bit
            //cout<<ans2<<'\n';
            while(numberOfZerosAtEnd){
                ans2/=2;
                numberOfZerosAtEnd--;
            }

            ans2 += multTwo*2;

        ///maradek
           tempN/=4;
           ans2 += tempN*4*multTwo;
           break;
        }
        else{
            ans2 += multTwo * (tempN%2);
        }

        multTwo *= 2;
        tempN /= 2;
    }
    cout<<ans2;





    return 0;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms1872 KiB
2Accepted0/02ms2220 KiB
3Accepted2/22ms2488 KiB
4Accepted2/22ms2548 KiB
5Partially correct1/22ms2752 KiB
6Partially correct1/22ms3004 KiB
7Accepted2/22ms3092 KiB
8Accepted4/42ms3240 KiB
9Accepted4/42ms3336 KiB
10Accepted4/42ms3408 KiB
11Accepted4/42ms3608 KiB
12Accepted4/42ms3808 KiB
13Accepted4/42ms3928 KiB
14Accepted4/42ms4032 KiB
15Accepted4/42ms4120 KiB
16Accepted4/42ms4088 KiB
17Accepted4/42ms4200 KiB