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

sdfdfg

Posted by 90401304 at 2005-01-03 11:03:44 on Problem 1012
#include <stdio.h>
#include <iostream.h>
void main(){
	long int m;
	int k,i,cur,per;
	cin>>k;
	while(k!=0){
	  if(k==1)cout<<"2"<<endl;
	  for(m=k+1;;m++){
		 if(m%(2*k)<=k)continue;
		 for(i=2,cur=m%(2*k),per=2*k-1;i<=k;i++){
			 if(cur==(per+1)){
				 cur=m%per;
				 if(cur<=k)break;
				 per--;
			 }
			 else{
				 cur=(m+cur-per-1)%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