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 wanpi0user at 2005-04-17 12:12:00 on Problem 2085
我的2085的解答代码
#include<iostream>
using namespace std;
int main(){
	int arr[50001],n,m,rev,i,j,t;
	while(1){
		cin>>n>>m;if(n==-1&&m==-1) break;
		for(i=1;i<=n;i++) arr[i]=i;
		rev=0;
		for(i=n-1;rev<m;i--){
			for(j=n;j>i;j--){
				t=arr[i];arr[i]=arr[j];arr[j]=t;
				if(++rev==m) break;
			}
		}
		for(i=1;i<=n;i++) cout<<arr[i]<<" ";
		cout<<endl;
	}
	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