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

为何会是limited time exceed?????救命!!!

Posted by 904013041 at 2005-01-03 18:08:09 on Problem 1012
#include <stdio.h>
#include <iostream.h>
void main(){
	long int m;
	int k,i,t=0,cur,per;
	cin>>k;
	while(k!=0){
	  for(m=k+1;;m++){
		 if(m%(k*2)==0)cur=k*2;
		 else cur=m%(2*k);
		 if(m%(k*2)<=k && m%(k*2)!=0)continue;
		 for(i=2,per=k*2-1;i<=k;i++){
			 if(cur==(per+1)){
				 cur=m%per;
                 if(cur==0)cur=per;
				 if(cur<=k)break;			 
				 per--;
			 }
			 else{
				 cur=(m+cur-per-1)%per;
				 if(cur==0) cur=per;
				 if(cur<=k)break;
				 per--;
			 }
		 }
		 if(per==k){
			 cout<<m<<endl;
			 break;}
	  }
	  cin>>k;
	}
}





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