백준 [ALGORITHM] - 카드1 (2161)
              
          2024. 1. 30. 14:51ㆍ코딩/백준 [ALGORITHM]
반응형
    
    
    
  from queue import Queue
N = int(input())
lst = [i + 1 for i in range(N)]
collect = []
for i in range(len(lst)):
    if len(lst) != 1:
        tmp1 = lst.pop(0)
        collect.append(tmp1)
        tmp = lst[0]
        lst.pop(0)
        lst.append(tmp)
    else:
        if len(" ".join(map(str, collect))+  " ".join(map(str, lst))) == 1:
            print("".join(map(str, lst)))
            break
        print(" ".join(map(str, collect)),  " ".join(map(str, lst)))반응형
    
    
    
  '코딩 > 백준 [ALGORITHM]' 카테고리의 다른 글
| 백준 [ALGORITHM] - 베스트셀러 (1302) (0) | 2024.02.03 | 
|---|---|
| 백준 [ALGORITHM] - 아이폰 9S (5883) (0) | 2024.02.02 | 
| 백준 [ALGORITHM] - 커트라인 (25305) (1) | 2024.01.28 | 
| 백준 [ALGORITHM] - 주사위 (1233) (0) | 2024.01.27 | 
| 백준 [ALGORITHM] - 문서 검색 (1543) (0) | 2024.01.25 |