using namespace std;
struct node
{
int data;
node* next;
};
void snode(int m,int s,int n)
{
node*head=0,*t,*p,*r;
int i;
for(i=1;i<=m;i++)//用鏈表順序輸入數據
{
p=new node;
p->data=i;
if(head==0)
head=p;
else
t->next=p;
t=p;
}
p->next=head;//循環鏈表 p爲頭
p=head;
for(i=1;i<s;i++)//找起始位置 r比p前一個
{
r=p;
p=p->next;
}
while(r!=p)//直到只剩一個
{
cout<<p->data<<" ";
r->next=p->next;
delete p ;
p=r->next;//去掉已報的數,把環接好
for(i=1;i<n;i++)//繼續找數
{
r=p;p=p->next;
}
}
cout<<p->data<<endl;//輸出最後一個
}
void main()
{
int m,s,n;
cin>>m>>s>>n;//m是總個數,s爲起始位置,n爲間隔數
snode(m,s,n);
}