Skip to content

Instantly share code, notes, and snippets.

@KimGaYeong
Created October 4, 2021 12:07
Show Gist options
  • Save KimGaYeong/7a611ab4041e9231da3167b2ed77fd0a to your computer and use it in GitHub Desktop.
Save KimGaYeong/7a611ab4041e9231da3167b2ed77fd0a to your computer and use it in GitHub Desktop.
from sys import stdin
N, K = map(int, stdin.readline().split())
yo = list(i for i in range(1, N+1))
result = []
now = 0 #now : 현재 위치를 나타냄
while len(yo) >1 :
now += K
if now > len(yo):
now = now % len(yo)
if now ==0:
now = now + len(yo)
now -= 1
result.append(yo.pop(now))
print("<", end = "")
for i in range(len(result)):
print(result[i], end = ", ")
print(yo.pop(), end = "")
print(">")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment