73502024-01-08 09:27:43szabelrAutókódoláscpp17Time limit exceeded 42/50300ms4496 KiB
// Autókódolás.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
    int  a,uj=0,n=1,egyesek=0,kisebb,nagyobb,ke=0,ne=0,kisebberedeti,nagyobberedeti;
    cin >> a;
    kisebb = a-1;
    nagyobb = a+1;
    kisebberedeti = kisebb;
    nagyobberedeti = nagyobb;

    while (a > 0)
    {
        if (a % 2 == 1)
            egyesek++;
        a = a / 2;
        n=n*10;
    }

    while (ke != egyesek)
    {
        n = 1;
        ke = 0;
        while (kisebb > 0)
        {
            if (kisebb % 2 == 1)
                ke++;
            kisebb = kisebb / 2;
            n = n * 10;
        }
        //cout << ke;
        if (ke == egyesek)
        {
            cout << kisebberedeti<<endl;
        }
        kisebberedeti--;
        if (kisebberedeti < 0) {
            cout << "-1"<<endl;
            break;
        }

        kisebb = kisebberedeti;
    }
    while (ne != egyesek)
    {
        n = 1;
        ne = 0;
        while (nagyobb > 0)
        {
            if (nagyobb % 2 == 1)
                ne++;
            nagyobb = nagyobb / 2;
            n = n * 10;
        }
        //cout << ke;
        if (ne == egyesek)
        {
            cout << nagyobberedeti;
        }
        nagyobberedeti++;

        nagyobb = nagyobberedeti;
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


SubtaskSumTestVerdictTimeMemory
base42/50
1Accepted0/03ms1876 KiB
2Time limit exceeded0/0300ms2040 KiB
3Accepted2/23ms2328 KiB
4Accepted2/23ms2500 KiB
5Accepted2/23ms2720 KiB
6Accepted2/23ms2956 KiB
7Accepted2/23ms2876 KiB
8Accepted4/43ms3128 KiB
9Accepted4/43ms3220 KiB
10Accepted4/43ms3220 KiB
11Accepted4/43ms3460 KiB
12Accepted4/43ms3828 KiB
13Time limit exceeded0/4298ms3876 KiB
14Accepted4/43ms3920 KiB
15Accepted4/49ms4060 KiB
16Accepted4/4129ms4288 KiB
17Time limit exceeded0/4263ms4496 KiB