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

Re:the Chinese remainder theorem

Posted by yesiam at 2005-03-12 09:06:41 on Problem 1006
In Reply To:请问大家怎样才能不超时?痛苦死了 Posted by:yeti at 2005-03-12 03:00:45
> #include<iostream.h>
> #include<math.h>
> void main()
> {
> 	
> 	int p,e,i,d,t=0,u=0;
> 	while(1){
> 		u++;
> 		cin>>p>>e>>i>>d;
> 		if(p==-1 && e==-1 && i==-1 && d==-1) break;
> 		for(t=d+1;;t++){
> 			if((t-p)%23==0 && (t-e)%28==0 && (t-i)%33==0){
> 					cout<<"Case "<<u
> 					<<": the next triple peak occurs in "
> 					<<t-d<<" days."<<endl;
> 					break;
> 				}
> 		}
> 		
> 	}
> }

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