75902024-01-09 21:24:36rennAutókódoláscpp17Partially correct 48/503ms4192 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

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

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

        if(most && !prev) {
            kicsi ^= (1LL << i);
            kicsi ^= (1LL << (i-1LL));
            h = 0;
            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;
        }
    }

    cout << (h < 0 ? h : kicsi) << "\n";
    cout << (j < 0 ? -1 : nagy) << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms2020 KiB
2Accepted0/03ms2192 KiB
3Accepted2/23ms2332 KiB
4Accepted2/23ms2584 KiB
5Partially correct1/23ms2620 KiB
6Partially correct1/23ms2680 KiB
7Accepted2/23ms2772 KiB
8Accepted4/43ms3016 KiB
9Accepted4/43ms3232 KiB
10Accepted4/43ms3404 KiB
11Accepted4/43ms3672 KiB
12Accepted4/43ms3756 KiB
13Accepted4/43ms3828 KiB
14Accepted4/43ms4064 KiB
15Accepted4/43ms4064 KiB
16Accepted4/43ms4036 KiB
17Accepted4/43ms4192 KiB