187372025-11-02 07:21:10birozsTáblajáték 2 (70 pont)python3Accepted 70/7017ms3320 KiB
N = int(input())
T = list(map(int,input().split()))
def DecToTre(x):
    harmas = ""
    if x == 0:
        return 0
    else:
        while x > 0:
            harmas = str(x % 3) + harmas
            x = x // 3
        return 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
base70/70
1Accepted0/017ms3124 KiB
2Accepted0/017ms3120 KiB
3Accepted2/216ms3320 KiB
4Accepted3/316ms3312 KiB
5Accepted3/316ms3172 KiB
6Accepted3/317ms3112 KiB
7Accepted3/316ms3320 KiB
8Accepted3/317ms3124 KiB
9Accepted3/316ms3124 KiB
10Accepted3/316ms3316 KiB
11Accepted3/316ms3320 KiB
12Accepted3/317ms3120 KiB
13Accepted3/316ms2952 KiB
14Accepted3/316ms3016 KiB
15Accepted4/417ms2924 KiB
16Accepted4/414ms2948 KiB
17Accepted4/416ms3132 KiB
18Accepted4/417ms3096 KiB
19Accepted4/416ms3152 KiB
20Accepted4/416ms3076 KiB
21Accepted4/416ms3148 KiB
22Accepted4/416ms3140 KiB
23Accepted3/316ms3152 KiB