Problems > Order of Elimination

Order of Elimination

Difficulty: 1300 3000 ms 128 MB

implementation

N people stand in a circle; counting from position 1, every K-th person is removed. Print the FULL elimination order.

Input: one line with two integers N and K.

Output: the N eliminated positions in order.

Constraints:

  • 1 ≤ N, K ≤ 3000

Sample Tests

Input 1
7 3
Output 1
3 6 2 7 5 1 4
Input 2
1 5
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.