75802024-01-09 20:35:36rennAutókódoláscpp17Partially correct 48/503ms3952 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 < 40; 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 || nagy > 1000000000000LL ? -1 : nagy) << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms1872 KiB
2Accepted0/03ms2068 KiB
3Accepted2/22ms2148 KiB
4Accepted2/23ms2180 KiB
5Partially correct1/23ms2376 KiB
6Partially correct1/23ms2740 KiB
7Accepted2/23ms2672 KiB
8Accepted4/43ms2884 KiB
9Accepted4/43ms3084 KiB
10Accepted4/43ms3100 KiB
11Accepted4/43ms3224 KiB
12Accepted4/43ms3312 KiB
13Accepted4/43ms3440 KiB
14Accepted4/43ms3652 KiB
15Accepted4/43ms3864 KiB
16Accepted4/43ms3944 KiB
17Accepted4/43ms3952 KiB