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 fuwutu at 2005-08-22 22:33:26 on Problem 1721
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
{
    int n,s,x[1000],y[1000],i,j;
    scanf("%d%d",&n,&s);
    for(i=1;i<=n;i++)
        scanf("%d",&x[i]);
    while(s--)
    {
        for(i=1;i<=n;i++)
        {
            y[i]=x[i];
            for(j=0;j<n/2;j++)
                y[i]=x[y[i]];
        }
        for(i=1;i<=n;i++)
            x[i]=y[i];
    }
    for(i=1;i<=n;i++)
        printf("%d\n",x[i]);

  system("PAUSE");
  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