187362025-11-02 07:17:30birozsTáblajáték 2 (70 pont)python3Runtime error 67/7017ms3368 KiB
N = int(input())
T = list(map(int,input().split()))
def DecToTre(x):
    harmas = ""
    while x > 0:
        harmas = str(x % 3) + harmas
        x = x // 3
    return int(harmas)

sor = 0
hely = 0
for i in range(N):
    if T[i] == 0:
        sor += 1
        hely = hely * 3
    elif T[i] == 1:
        sor += 1
        hely = hely * 3 + 1
    elif T[i] == 2:
        sor += 1
        hely = hely * 3 + 2
    elif T[i] == 3:
        sor -= 1
        hely = hely // 3
    elif T[i] == 4:
        hely = hely - 1
    else:
        hely = hely + 1
print(sor)
print(DecToTre(hely))
SubtaskSumTestVerdictTimeMemory
base67/70
1Accepted0/016ms3140 KiB
2Accepted0/016ms3120 KiB
3Accepted2/216ms3124 KiB
4Accepted3/316ms3112 KiB
5Accepted3/317ms3124 KiB
6Accepted3/317ms3124 KiB
7Accepted3/316ms3124 KiB
8Accepted3/316ms3124 KiB
9Accepted3/316ms3076 KiB
10Accepted3/316ms3144 KiB
11Accepted3/316ms3368 KiB
12Accepted3/317ms2992 KiB
13Accepted3/317ms3128 KiB
14Accepted3/316ms3124 KiB
15Accepted4/417ms3128 KiB
16Accepted4/416ms3124 KiB
17Accepted4/417ms3124 KiB
18Accepted4/417ms3124 KiB
19Accepted4/417ms3124 KiB
20Accepted4/417ms3320 KiB
21Accepted4/416ms3124 KiB
22Accepted4/416ms2988 KiB
23Runtime error0/316ms2996 KiB