34 lines
477 B
C
34 lines
477 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int rs[105],n,m,xcz;
|
|
|
|
int zj(int a){
|
|
a++;
|
|
if(a>n) a-=n;
|
|
while(rs[a]==0&&xcz>0){
|
|
a++;
|
|
if(a>n) a-=n;
|
|
}
|
|
return a;
|
|
}
|
|
|
|
int main(){
|
|
//freopen("title.txt","r",stdin);
|
|
scanf("%d%d",&n,&m);
|
|
xcz=n;
|
|
for(int i=1;i<=n;i++) rs[i]=1;
|
|
for(int i=m;xcz>0;){
|
|
if(rs[i]==1){
|
|
rs[i]=0;
|
|
xcz--;
|
|
printf("%d ",i);
|
|
}
|
|
int ls=m;
|
|
while(ls--) i=zj(i);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 尚未修改到课程版本
|
|
// Ref: P1996 约瑟夫问题
|