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

ft...........这两个有关系么

Posted by frkstyc at 2005-07-04 11:25:14 on Problem 2182
In Reply To:只有计算概论,程序设计实习的基础,怎么省时呢? Posted by:00 at 2005-07-04 10:57:02
> #include<iostream.h>
> void main()
> {
> 	int N,i,j,k,p;
> 	int *a,*b,*r;
> 	cin>>N;
> 	a=new int[N];
> 	b=new int[N];
> 	r=new int[N];
> 	for(i=1;i<N;i++)
> 	{
> 		cin>>a[i];
> 		b[i]=i+1;
> 	}
> 	b[0]=1;
> 	for(i=N-1,k=N-1;i>0;i--)
> 	{
> 		if(i==N-1)
> 		{
> 			r[i]=a[i]+1;
> 			for(j=r[i]-1;j<k;j++)
> 				b[j]=b[j+1];
> 		}
> 		else
> 		{
> 			for(j=0;j<k;j++)
> 			{
> 				int x=0;
> 				for(p=N-1;p>i;p--)
> 				{
> 					if(r[p]<b[j])
> 						x++;
> 				}
> 				if(b[j]==a[i]+x+1)
> 				{
> 					k--;
> 					r[i]=b[j];
> 					for(p=j;p<k;p++)
> 						b[p]=b[p+1];
> 					break;
> 				}
> 			}
> 		}
> 	}
> 	cout<<b[0]<<endl;
> 	for(i=1;i<N;i++)
> 		cout<<r[i]<<endl;
> 	delete [] a;
> 	delete [] b;
> 	delete [] r;
> }

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