//2014年-约瑟夫环
#include<stdio.h>
#include<stdlib.h>//里面就有malloc.H了,可以不用加malloc
#define LEN sizeof(Lnode)
typedef struct Lnode{
int data;
struct Lnode *next;
}Lnode,*LinkList;
int main(void)
{
//n个人,报数m
int n,m,i;
scanf("%d%d",&n,&m);
int remain=n;
int number_off=0;
//创建循环链表
Lnode *L = (Lnode *)malloc(LEN);
Lnode *p,*q;
p=L;
L->data = 1;
for(i=2;i<=n;i++)
{
p->next = (Lnode *)malloc(LEN);
p=p->next;
p->data = i;
}
p->next = L;
p=L;
while(remain>0)
{
if(p->data !=0)
{
number_off++;
if(number_off==m)
{
number_off=0;
remain--;
printf("%d ",p->data);
p->data=0;
}
}
p=p->next;
}
return 0;
}