#P1996. Josephus Elimination Order
Josephus Elimination Order
Josephus Elimination Order
There are \(n\) people arranged in a circle. Starting from the first person, count sequentially from 1. When the count reaches \(m\), the corresponding person is eliminated from the circle. The counting then restarts from 1 with the next person after the eliminated one. This process continues until everyone has been eliminated. The task is to output the order in which the people are eliminated.
Note: This problem is stated differently from the example in "In-depth Basics" where only \(n-1\) people are eliminated. In this problem, all \(n\) people are eliminated.
inputFormat
The input consists of a single line containing two positive integers \(n\) and \(m\) separated by a space, where \(n\) is the number of people and \(m\) is the count at which a person is eliminated.
outputFormat
Output the elimination order of the people as a sequence of integers separated by a single space.
sample
5 2
2 4 1 5 3