75962024-01-10 00:33:35rennAutókódoláscpp14Partially correct 47/503ms3984 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

    long long nagy, kicsi, j = -1, h = 0;
    cin >> nagy;

    //bitset<40> a(nagy);
    kicsi = nagy;

    bool prev = true, most = true;
    for(long long i = 0, k; i < 41; i++) {
        prev = most;
        most = (kicsi & (1LL << i));

        h += most;
        kicsi ^= ((long long)most << i);
        if(most && !prev) {
            //kicsi ^= (0LL << (i));

            for(k = 0; k < h; k++) {
                kicsi ^= (1LL << (i-k-1));
            }
            break;
        }
    }

    prev = most = false;
    for(long long i = 0, k; i < 41; i++) {
        prev = most;
        most = (nagy & (1LL << i));

        j += most;

        nagy ^= ((long long)most << i);
        if(!most && prev) {
            nagy ^= (1LL << i);

            for(k = 0; k < j; k++) {
                nagy ^= (1LL << k);
            }
            break;
        }
    }
    //bitset<40> b(kicsi);
    //bitset<40> c(nagy);
    //cout << a << "\n";
    cout << (h < 1 ? h : kicsi) << "\n";
    //out << b << "\n";
    cout << nagy << "\n";
    //cout << c << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base47/50
1Accepted0/03ms1872 KiB
2Accepted0/03ms2068 KiB
3Partially correct1/23ms2436 KiB
4Accepted2/23ms2436 KiB
5Accepted2/22ms2508 KiB
6Accepted2/23ms2512 KiB
7Accepted2/23ms2796 KiB
8Accepted4/43ms2860 KiB
9Accepted4/43ms2872 KiB
10Accepted4/43ms3064 KiB
11Accepted4/42ms3152 KiB
12Accepted4/43ms3276 KiB
13Partially correct2/43ms3388 KiB
14Accepted4/43ms3480 KiB
15Accepted4/42ms3472 KiB
16Accepted4/43ms3724 KiB
17Accepted4/43ms3984 KiB