75882024-01-09 21:20:03rennAutókódoláscpp17Partially correct 48/503ms3868 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 || nagy > 1000000000000LL ? -1 : nagy) << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2072 KiB
3Accepted2/23ms2304 KiB
4Accepted2/23ms2556 KiB
5Partially correct1/23ms2768 KiB
6Partially correct1/23ms2860 KiB
7Accepted2/23ms2860 KiB
8Accepted4/43ms3052 KiB
9Accepted4/43ms3300 KiB
10Accepted4/43ms3372 KiB
11Accepted4/43ms3568 KiB
12Accepted4/42ms3628 KiB
13Accepted4/42ms3632 KiB
14Accepted4/43ms3760 KiB
15Accepted4/43ms3772 KiB
16Accepted4/43ms3740 KiB
17Accepted4/43ms3868 KiB