๐Ÿ—๏ธ Algorithm/๐ŸŸฉ ๋ฐฑ์ค€

[๋ฐฑ์ค€] [Python] 2164๋ฒˆ_์นด๋“œ2_ํ,๋ฑ

Dbswnstjd 2022. 10. 14. 21:30

๋ฌธ์ œ

https://www.acmicpc.net/problem/2164

 

2164๋ฒˆ: ์นด๋“œ2

N์žฅ์˜ ์นด๋“œ๊ฐ€ ์žˆ๋‹ค. ๊ฐ๊ฐ์˜ ์นด๋“œ๋Š” ์ฐจ๋ก€๋กœ 1๋ถ€ํ„ฐ N๊นŒ์ง€์˜ ๋ฒˆํ˜ธ๊ฐ€ ๋ถ™์–ด ์žˆ์œผ๋ฉฐ, 1๋ฒˆ ์นด๋“œ๊ฐ€ ์ œ์ผ ์œ„์—, N๋ฒˆ ์นด๋“œ๊ฐ€ ์ œ์ผ ์•„๋ž˜์ธ ์ƒํƒœ๋กœ ์ˆœ์„œ๋Œ€๋กœ ์นด๋“œ๊ฐ€ ๋†“์—ฌ ์žˆ๋‹ค. ์ด์ œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋™์ž‘์„ ์นด๋“œ๊ฐ€

www.acmicpc.net

ํ’€์ด

from collections import deque
 
n,k = map(int,input().split())
queue = deque()
 
for i in range(1,n+1):
    queue.append(i)

print("<",end='')
while queue:
    for _ in range(k-1):
        queue.append(queue.popleft())
    print(queue.popleft(),end="")    
    if queue:
        print(", ",end="")
 
print(">")