#include <cstdio>
#include <cstring>
int main()
{
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
int N,k,m;
int q[25];
while(scanf("%d%d%d",&N,&k,&m))
{
if(N==0 && k==0 && m==0)
break;
memset(q,0,sizeof(q));
for(int i=0;i<N;i++)
q[i]=i+1;
int u1,u2,h;
u1=-1;
u2=N;
h=N;
while(h>0)
{
if(h!=N)
printf(",");
int g;
g=0;
while(g!=k)
{
u1=(u1+1)%N;
if(q[u1]!=-1)
g++;
}
printf("%3d",q[u1]);
h--;
g=0;
while(g!=m)
{
u2=(u2-1+N)%N;
if(q[u2]!=-1)
g++;
}
if(u2!=u1)
{
printf("%3d",q[u2]);
h--;
}
q[u1]=q[u2]=-1;
}
printf("\n");
}
return 0;
}
133 - The Dole Queue
最新推荐文章于 2024-02-13 13:56:13 发布