#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
int n,m,k,f1,f2,s1,s2,p,q,count,a[20];
while(cin>>n>>k>>m){
if(!n)
break;
for(p=0;p<20;p++)
a[p]=1;
count=n,f1=-1,f2=n;//f1第一步到0,f2第一步n-1;
while(count){
p=k%count?k%count:count,q=m%count?m%count:count;//若直接令p=k,q=m,会TLE
while(p--){
do
f1=(f1+1)%n;
while(!a[f1]);
}
s1=f1,count--;
while(q--){
do
f2=(f2-1+n)%n;
while(!a[f2]);
}
s2=f2,a[f1]=0,a[f2]=0;
if(s2!=s1){
count--;
printf("%3d%3d",s1+1,s2+1);
}
else
printf("%3d",s1+1);
if(count)
cout<<',';
else
cout<<endl;
}
}
return 0;
}
UVA - 133 The Dole Queue
最新推荐文章于 2023-11-29 23:20:39 发布