75772024-01-09 20:26:06rennAutókódoláscpp17Partially correct 48/503ms4040 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 < 64; 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 < 64; 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 ? j : nagy) << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2116 KiB
3Accepted2/23ms2320 KiB
4Accepted2/23ms2532 KiB
5Partially correct1/23ms2672 KiB
6Partially correct1/23ms2584 KiB
7Accepted2/23ms2712 KiB
8Accepted4/43ms2928 KiB
9Accepted4/43ms3012 KiB
10Accepted4/43ms3140 KiB
11Accepted4/43ms3384 KiB
12Accepted4/43ms3496 KiB
13Accepted4/43ms3740 KiB
14Accepted4/43ms3884 KiB
15Accepted4/43ms3852 KiB
16Accepted4/43ms4012 KiB
17Accepted4/43ms4040 KiB