#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct child{
int id;
int next;
};
int main(){
int n,m,k,total;
int count;
int head;
child a[55];
while(scanf("%d%d%d",&n,&m,&k)){
head=1;
total=n;
for(int i=0;i<n;i++){
a[i].id=i;
a[i].next=(i+1)%n;
}
int p=0;
count=m-1;
while(n>k){
p=a[p].next;
count--;
if(count==0){
count=m-1;
if(a[p].next==head) head=a[a[p].next].next;
a[p].next=a[a[p].next].next;
n--;
}
}
//while(a[p].next>a[p].id) p=a[p].next;
p=head;
//if(!p) p=a[p].next;
int t=1;
do{
if(!t){ printf(" ");}
if(p) printf("%d",p);
else printf("%d",total);
p=a[p].next;
t=0;
}while(--k);
printf("\n");
}
return 0;
}
zjut1220 N个胜利者
最新推荐文章于 2022-11-27 10:33:09 发布