64572023-12-02 11:42:30TulDavAutókódoláscpp11Time limit exceeded 33/50298ms3944 KiB
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#define ll long long
#define vll vector<ll>


ll tobincount(ll n)
{
    string sol = "";
    while (n >= 1)
    {
        switch (n % 2)
        {
        case 0:
            sol += "0";
            break;
        case 1:
            sol += "1";
            break;
        }

        n /= 2;
        //cout << n << " " << sol << endl;
    }
    //cout << sol;
    //reverse(sol.begin(), sol.end());
    //cout << sol;
    return count(sol.begin(), sol.end(), '1');
}




int main()
{
    ll n; cin >> n;

    ll m = n-1;

    while (tobincount(m) != tobincount(n) && m > 0)
    {
        m--;
    }
    if (m == 0) 
    {
        cout << -1;
        return 0;
    }
    cout << m << endl;
    m = n + 1;
    while (tobincount(m) != tobincount(n))
    {
        m++;
    }
    cout << m;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base33/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0298ms1820 KiB
3Partially correct1/23ms2072 KiB
4Accepted2/23ms2280 KiB
5Accepted2/23ms2500 KiB
6Accepted2/23ms2712 KiB
7Accepted2/23ms2924 KiB
8Accepted4/43ms3000 KiB
9Accepted4/43ms3132 KiB
10Accepted4/43ms3248 KiB
11Accepted4/43ms3380 KiB
12Accepted4/43ms3472 KiB
13Time limit exceeded0/4298ms3548 KiB
14Accepted4/48ms3600 KiB
15Time limit exceeded0/4211ms3708 KiB
16Time limit exceeded0/4277ms3784 KiB
17Time limit exceeded0/4273ms3944 KiB