Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴一下自己的代码。^_^

Posted by fanhqme at 2008-09-30 10:34:30 on Problem 1026
#include <cstdio>
using namespace std;
int main()
{
    int next[200],queue[200][200],qlenth[200],N,k,j,i;
    char datas[500],ans[500];
    for (scanf("%d",&N);N;scanf("%d",&N)){
        for (i=0;i<N;i++)scanf("%d",next+i);
        for (i=0;i<N;i++)next[i]--;
        for (i=0;i<N;i++){
            j=i;queue[i][0]=j;qlenth[i]=1;
            for (j=next[j];j!=i;j=next[j])
                queue[i][qlenth[i]++]=j;
        }
        for (scanf("%d",&k);k;scanf("%d",&k)){
            getchar();
            gets(datas);
            for (i=0;datas[i] && datas[i]!=10;i++);
            for (;i<N;i++)datas[i]=' ';
            for (i=0;i<N;i++)ans[queue[i][k%qlenth[i]]]=datas[i];
            ans[N]=0;
            puts(ans);
        }
        printf("\n");
    }
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator