Core Games!!

4.1

9 votes
Easy-Medium
Problem

Tapas and Meghana are appointed as the one responsible for interviews of AXIS Core committee '17 ! In order to decide upon the order in which to call the aspirants for the interview, they have come up with a brilliant game. It goes like: the core game is divided into N phases; and N aspirants, successively numbered from 1 to N, are moving round a circle one after another, i.e. the first follows the second, the second follows the third, ..., the (N-1)-th follows the N-th, and the N-th follows the first. At each phase, a single aspirant is made to leave the circle and is taken up for interview. While the others continue to move. At some phase, the circle is left by an aspirant, who is marching K positions before the one, who left the circle at the previous phase. An aspirant, whose number is K, leaves the circle at the first phase.

Input
The only line contains the integer numbers N , and K .

Output
You should output the order in which in the aspirants give their interviews. The numbers should be separated by single spaces.

Constraints
1<=N<=100000
1<=K<=N

Sample Input
5 3
Sample Output
3 1 5 2 4
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?