21162022-12-20 12:20:441478Autókódoláscpp11Wrong answer 43/503ms3908 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(tempN == 0) cout<<-1;
    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
base43/50
1Accepted0/03ms2004 KiB
2Wrong answer0/02ms2432 KiB
3Partially correct1/22ms2324 KiB
4Wrong answer0/22ms2536 KiB
5Partially correct1/22ms2732 KiB
6Partially correct1/22ms2936 KiB
7Accepted2/22ms3148 KiB
8Accepted4/42ms3260 KiB
9Accepted4/42ms3476 KiB
10Accepted4/42ms3396 KiB
11Accepted4/42ms3524 KiB
12Accepted4/42ms3628 KiB
13Partially correct2/42ms3704 KiB
14Accepted4/42ms3828 KiB
15Accepted4/42ms3908 KiB
16Accepted4/42ms3908 KiB
17Accepted4/42ms3908 KiB