๐๏ธ 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(">")