76042024-01-10 01:05:39rennAutókódoláscpp17Accepted 50/503ms3880 KiB
#include <bits/stdc++.h>
#define ll long long
#define S 42

using namespace std;

ll N, kovval = 0, elozoval = 0, i;
bool elozo[S], kov[S], nincs_elozo;

int main() {

    cin >> N;

    for(ll i = 0; i < S; i++) {
        kov[S-1-i] = elozo[S-1-i] = N & (1LL << i);
    }

    nincs_elozo = prev_permutation(elozo, elozo + S);
    next_permutation(kov, kov + S);

    for(i = (S-1)*nincs_elozo; i >= 0; --i) {
        elozoval |= ((ll)elozo[i] << (S-1-i));
    }
    for(i = S-1; i >= 0; --i) {
        kovval |= ((ll)kov[i] << (S-1-i));
    }

    cout << (!nincs_elozo ? -1LL : elozoval) << "\n" << kovval << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1880 KiB
2Accepted0/03ms2116 KiB
3Accepted2/22ms2200 KiB
4Accepted2/23ms2396 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2756 KiB
7Accepted2/23ms2940 KiB
8Accepted4/43ms3064 KiB
9Accepted4/43ms3464 KiB
10Accepted4/43ms3536 KiB
11Accepted4/43ms3612 KiB
12Accepted4/43ms3672 KiB
13Accepted4/42ms3752 KiB
14Accepted4/42ms3876 KiB
15Accepted4/42ms3872 KiB
16Accepted4/42ms3756 KiB
17Accepted4/43ms3880 KiB