//置换差不多搞懂了,就是换来换去的,可惜又看了别人的程序了………… #include<stdio.h> #include<string.h> int a[1005],cont,b[1005],c[1005],n,x; void solve(){ int i; while(1){ for(i=1;i<=n;i++){ b[i]=c[c[i]]; } cont++; for(i=1;i<=n;i++){ if(b[i]!=a[i]) break; } if(i>n) break; for(i=1;i<=n;i++){ c[i]=b[i]; } } return; } int main(){ int i,t,temp,s; while(scanf("%d%d",&n,&s)!=EOF){ for(i=1;i<=n;i++){ scanf("%d",&a[i]); c[i]=a[i]; } cont=0; solve(); temp=s%cont; temp=cont-temp; int q=0; while(q<temp){ for(i=1;i<=n;i++){ c[i]=a[a[i]]; } for(i=1;i<=n;i++){ a[i]=c[i]; } q++; } for(i=1;i<=n;i++){ printf("%d\n",a[i]); } } return 0; }