#include<stdio.h> int main(){ int n,m,p,left,right; int sum; int num[50010]; while(~scanf("%d%d%d%d%d",&n,&m,&p,&left,&right)){ sum=0; int kk=n/m; int th=1; th*=m;sum++; while(1){ if(th==1)break; if(th<=kk){th*=m;sum++;} else {th=(th-kk-1)/(m-1)+th-kk;sum++;} } // printf("xuanhuan==%d ",sum); p%=sum; for(int i=1;i<=n;i++){ int my=i; for(int j=1;j<=p;j++){ if(my<=kk){my*=m;} else {my=(my-kk-1)/(m-1)+my-kk;} } // printf("%d ",my); num[my]=i; } for(int ll=left;ll<=right;ll++) { if(ll==left)printf("%d",num[ll]); else printf(" %d",num[ll]); } printf(" "); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。