75972024-01-10 00:37:35rennAutókódoláscpp14Wrong answer 45/503ms3996 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 ^= (1 << 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";
    //cout << b << "\n";
    cout << nagy << "\n";
    //cout << c << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/03ms2140 KiB
2Wrong answer0/03ms2328 KiB
3Partially correct1/23ms2424 KiB
4Accepted2/23ms2480 KiB
5Accepted2/23ms2516 KiB
6Accepted2/23ms2584 KiB
7Accepted2/23ms2716 KiB
8Accepted4/43ms2972 KiB
9Accepted4/43ms3204 KiB
10Accepted4/43ms3208 KiB
11Accepted4/43ms3308 KiB
12Accepted4/43ms3540 KiB
13Wrong answer0/43ms3596 KiB
14Accepted4/43ms3784 KiB
15Accepted4/43ms3836 KiB
16Accepted4/43ms3948 KiB
17Accepted4/43ms3996 KiB