Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 858 Bytes

File metadata and controls

43 lines (33 loc) · 858 Bytes

백준 4779번 칸토어 집합

4779


소스코드

  • 메모리 : 31100 KB
  • 시간 : 84 ms
def split(stick, index):
    size = len(stick)
    if size == 3 and index != 1:
        return '- -'
    elif size >= 3 and index == 1:
        return stick.replace('-', ' ')

    lst = []

    for i in range(0, size, size // 3):
        lst.append(bar[i:i+size//3])

    answer = split(lst[0], 0) + split(lst[1], 1) + split(lst[2], 2)
    return answer


while 1:
    try:
        n = int(input())
    except EOFError:
        break
    num = 3 ** n
    if num == 1:
        print('-')
        continue

    bar = '-' * num
    lst = split(bar, 0)
    print(lst)