fork download
  1. # your code goes here
  2. a = list(map(int, input().split()))
  3.  
  4. b=[]
  5. for i in range(1,a[0]+1):
  6. b.append(i)
  7.  
  8. c=[]
  9. while len(b) != 0:
  10. d=[]
  11. if len(b) < a[1]:
  12. front = a[1] % len(b) -1
  13. else:
  14. front = a[1]-1
  15. c.append(b[front])
  16. b.pop(front)
  17. for i in range(len(b)):
  18. d.append(b[(front + i) % len(b)])
  19. b = d
  20.  
  21.  
  22. result = ", ".join(map(str,c))
  23. print("<" +result +">")
  24.  
  25. # Answer : <6, 1, 3, 2, 5, 4>
  26.  
Success #stdin #stdout 0.04s 9812KB
stdin
6 6
stdout
<6, 1, 3, 2, 4, 5>