199152025-12-29 15:08:30szjAutókódoláscpp17Wrong answer 44/501ms596 KiB
#include <bits/stdc++.h>

using namespace std;
void re(string a)
{
    long long m=0, d=1;
    for(int i=a.length()-1; i>=0; i--)
    {
        m+=d*(a[i]-'0');
        d*=2;
    }
    cout << m << endl;
}
int main()
{
    long long n;
    cin >> n;
    string a="", b;
    while(n)
    {
        a=char(n%2+'0')+a;
        n/=2;
    }
    a='0'+a;
    b=a;
    if(prev_permutation(b.begin(), b.end()))
    {
        re(b);
    }
    else cout << -1;
    next_permutation(a.begin(), a.end());
    re(a);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/01ms596 KiB
2Accepted0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms500 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms324 KiB
7Accepted2/21ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/41ms564 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms528 KiB
13Wrong answer0/41ms316 KiB
14Accepted4/41ms316 KiB
15Accepted4/41ms316 KiB
16Accepted4/41ms316 KiB
17Accepted4/41ms316 KiB