1
2
3
4
5
6
7
8
9
10
11
12
|
import collections
tmp=collections.deque()
for i in range(1,int(input())+1):
tmp.append(i)
ans=[]
while len(tmp)!=1:
ans.append(tmp[0])
tmp.popleft()
tmp.append(tmp[0])
tmp.popleft()
ans.append(tmp[0])
print(*ans)
|
cs |
크게 어려운 부분은 없구요 자료구조(Data structure)를
deque로 이용해서 구현했습니다.
반응형
댓글