Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁能告诉我,我的程序为什么超时?我的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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator