144902025-01-12 15:01:05fzs1969Autókódoláspython3Wrong answer 0/5017ms3336 KiB
def kettesbe(szám):
    számjegyek = []
    while szám > 0:
        számjegyek.append(szám % 2)
        szám = szám // 2
    számjegyek.append(0)
    return számjegyek
def számmá(számjegyek):
    érték = 0
    hossz = len(számjegyek)
    for i in range(hossz-1, 0-1, -1):
        érték = 2*érték + számjegyek[i]
    return érték

kód = int(input())
lista = kettesbe(kód)
print(lista)
# nagyobb
hely = 0
while lista[hely] == 0:
    hely += 1
db = 0
while lista[hely] == 1:
    lista[hely] = 0
    hely += 1
    db += 1
lista[hely] = 1
for i in range(db-1):
    lista[i] = 1
# print(lista)
következő = számmá(lista)
# előző meghatározása
lista = kettesbe(kód)+[0]
hely = 0
if lista[0] == 1:
    while lista[hely] == 1:
        hely += 1
    print(hely, len(lista))
    if hely != len(lista)-2:
        while lista[hely] == 0:
            hely += 1
        lista[hely] = 0
        lista[hely-1] = 1
        lista = sorted(lista[:(hely-1)]) + lista[hely-1:]
        előző = számmá(lista)
    else:
        előző = -1
else:
    while lista[hely] == 0:
        hely += 1
    print(hely)
    lista[hely] = 0
    lista[hely-1] = 1
    előző = számmá(lista)
print(előző)
print(következő)
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/016ms3140 KiB
2Wrong answer0/016ms3124 KiB
3Wrong answer0/216ms3308 KiB
4Wrong answer0/217ms3124 KiB
5Wrong answer0/216ms3312 KiB
6Wrong answer0/216ms3272 KiB
7Wrong answer0/216ms3124 KiB
8Wrong answer0/417ms3124 KiB
9Wrong answer0/417ms3072 KiB
10Wrong answer0/416ms3264 KiB
11Wrong answer0/416ms3336 KiB
12Wrong answer0/417ms3232 KiB
13Wrong answer0/416ms3132 KiB
14Wrong answer0/417ms3124 KiB
15Wrong answer0/417ms3124 KiB
16Wrong answer0/416ms3124 KiB
17Wrong answer0/417ms3124 KiB