一个关于密码的问题,地址:http://acm.pku.edu.cn/JudgeOnline/problem?id=1026
#include "stdio.h"
int num[205];
int len[205];
int chang[205][205];
char temp[205];
int main()
{
    
int n,k;
    
int addr,i,j,t;
    
char ch;
    
while(1)
    
{
        scanf(
"%d",&n);
        
if(n==0)break;
        
for(i=0;i<n;i++){scanf("%d",&num[i]);len[i]=1;}
        
for(i=0;i<n;i++)
        
{
            chang[i][
0]=i;
            
for(j=1;j<n;j++)
            
{
                t
=chang[i][j-1];
                
if(num[t]-1==i)break;
                chang[i][j]
=num[t]-1;
                len[i]
++;
            }

        }

        
while(1)
        
{
            scanf(
"%d",&k);
            
if(k==0){printf("\n");break;}
            addr
=0;
            ch
=getchar();
            
for(i=0;i<n;i++)temp[i]=' ';
            
while((ch=getchar())!='\n')temp[chang[addr++][k%len[addr]]]=ch;
            
for(i=0;i<n;i++)printf("%c",temp[i]);
            printf(
"\n");
        }

    }

    
return 0;
}