95662024-02-23 10:16:31AGergoAutókódoláscpp17Accepted 50/503ms3852 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    cin.tie(0);ios::sync_with_stdio(0);
    long long  szam,p=0,n=0;
    cin >> szam;
    bitset<64> bin(szam);
    vector<int> prev(64,0);
    vector<int> next(64,0);

    for(int i = 0; i < 64;i++)
    {
        prev[i] = bin[i];
        next[i] = bin[i];
    }
    reverse(prev.begin(),prev.end());
    reverse(next.begin(),next.end());

    if(prev_permutation(prev.begin(),prev.end()))
    {
        reverse(prev.begin(),prev.end());
        for(int i = 0; i < 64;i++)
        {
            p+= prev[i]*pow(2,i);
        }
        cout << p << endl;
    }
    else { cout << "-1\n";}
    if(next_permutation(next.begin(),next.end()))
    {
        reverse(next.begin(),next.end());
        for(int i = 0; i < 64;i++)
        {
            n+= next[i]*pow(2,i);
        }
        cout << n;
    }
    else { cout << "-1\n";}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/03ms2184 KiB
3Accepted2/23ms2328 KiB
4Accepted2/23ms2536 KiB
5Accepted2/23ms2628 KiB
6Accepted2/23ms2728 KiB
7Accepted2/23ms2828 KiB
8Accepted4/43ms2956 KiB
9Accepted4/43ms3164 KiB
10Accepted4/43ms3376 KiB
11Accepted4/42ms3464 KiB
12Accepted4/43ms3472 KiB
13Accepted4/43ms3472 KiB
14Accepted4/43ms3608 KiB
15Accepted4/43ms3704 KiB
16Accepted4/43ms3696 KiB
17Accepted4/43ms3852 KiB